5 |
my $dir; |
my $dir; |
6 |
my $out_dir; |
my $out_dir; |
7 |
my $file_pattern; |
my $file_pattern; |
8 |
|
my $domtest2perl = 'domtest2perl.pl'; |
9 |
GetOptions ( |
GetOptions ( |
10 |
|
'domtest2perl-path=s' => \$domtest2perl, |
11 |
'test-directory=s' => \$dir, |
'test-directory=s' => \$dir, |
12 |
'test-file-pattern=s' => \$file_pattern, |
'test-file-pattern=s' => \$file_pattern, |
13 |
'output-directory=s' => \$out_dir, |
'output-directory=s' => \$out_dir, |
14 |
); |
) or die; |
15 |
$dir or die "$0: test-directory must be specified"; |
$dir or die "$0: test-directory must be specified"; |
16 |
$out_dir or die "$0: output-directory must be specified"; |
$out_dir or die "$0: output-directory must be specified"; |
17 |
$file_pattern ||= qr/\.xml$/; |
$file_pattern ||= qr/\.xml$/; |
18 |
|
|
19 |
opendir my $dirh, $dir or die "$0: $dir: $!"; |
opendir my $dirh, $dir or die "$0: $dir: $!"; |
20 |
for (grep {$_ ne 'alltests.xml'} grep /$file_pattern/, readdir $dirh) { |
for (grep {$_ ne 'alltests.xml'} grep /$file_pattern/, readdir $dirh) { |
21 |
|
my $in_file = $dir.'/'.$_; |
22 |
my $out_file = $out_dir.'/'.$_.'.pl'; |
my $out_file = $out_dir.'/'.$_.'.pl'; |
23 |
|
if (-e $out_file and -C $in_file >= -C $out_file) { |
24 |
|
warn "$0: $_.pl: Skipped; it is newer than $_"; |
25 |
|
next; |
26 |
|
} |
27 |
my @cmd = ('perl', map ({"-I$_"} @INC), |
my @cmd = ('perl', map ({"-I$_"} @INC), |
28 |
'domtest2perl.pl', $dir.'/'.$_, |
$domtest2perl, $in_file, |
29 |
'--output-file' => $out_file); |
'--output-file' => $out_file); |
30 |
print STDERR join " ", @cmd, "\n"; |
print STDERR join " ", @cmd, "\n"; |
31 |
system @cmd and die "$0: domtest2perl.pl: $@"; |
system @cmd and die "$0: $domtest2perl: $@"; |
32 |
system 'perl', map ({"-I$_"} @INC), '-c', $out_file |
system 'perl', map ({"-I$_"} @INC), '-c', $out_file |
33 |
and die "$0: $out_file: $@"; |
and die "$0: $out_file: $@"; |
34 |
} |
} |