-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,3 +67,4 @@ util/posts.sql | |
ngx_openresty-* | ||
work/ | ||
reindex | ||
t/*.t_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
sub cd ($); | ||
|
||
my $ver = `bash util/ver`; | ||
chomp $ver; | ||
|
||
cd "ngx_openresty-$ver/bundle"; | ||
|
||
opendir(my $dh, '.') or | ||
die "cannot opendir .: $!"; | ||
|
||
my @dirs = grep { /\d+\.\d+/ && -d "$_" } readdir($dh); | ||
|
||
closedir $dh; | ||
|
||
cd '../../t'; | ||
|
||
opendir($dh, '.') or | ||
die "cannot opendir .: $!"; | ||
|
||
my @t_files = grep { /\.t$/ } readdir($dh); | ||
|
||
closedir $dh; | ||
|
||
for my $t_file (@t_files) { | ||
open my $in, $t_file or | ||
die "Cannot open $t_file for reading: $!\n"; | ||
|
||
my $outfile = $t_file . '_'; | ||
open my $out, ">$outfile" or | ||
die "Cannot open $outfile for writing: $!\n"; | ||
|
||
my $changed; | ||
while (<$in>) { | ||
for my $dir (@dirs) { | ||
(my $pat = $dir) =~ s/\d.*//; | ||
my $orig = $_; | ||
if (s{\.\./$pat\S+}{../$dir}g && $orig ne $_) { | ||
$changed++; | ||
|
||
warn "\n- $orig"; | ||
warn "+ $_"; | ||
} | ||
} | ||
|
||
print $out $_; | ||
} | ||
|
||
close $out; | ||
|
||
warn "Wrote t/$outfile\n"; | ||
|
||
close $in; | ||
} | ||
|
||
print join "\n", @dirs; | ||
|
||
sub cd ($) { | ||
my $dir = shift; | ||
print("cd $dir\n"); | ||
chdir $dir or die "failed to cd $dir: $!\n"; | ||
} | ||
|