1 |
#!/usr/bin/perl -w |
2 |
use strict; |
3 |
|
4 |
use Getopt::Long; |
5 |
my $dir; |
6 |
my $out_dir; |
7 |
my $file_pattern; |
8 |
GetOptions ( |
9 |
'test-directory=s' => \$dir, |
10 |
'test-file-pattern=s' => \$file_pattern, |
11 |
'output-directory=s' => \$out_dir, |
12 |
); |
13 |
$dir or die "$0: test-directory must be specified"; |
14 |
$out_dir or die "$0: output-directory must be specified"; |
15 |
$file_pattern ||= qr/\.xml$/; |
16 |
|
17 |
opendir my $dirh, $dir or die "$0: $dir: $!"; |
18 |
for (grep {$_ ne 'alltests.xml'} grep /$file_pattern/, readdir $dirh) { |
19 |
my $out_file = $out_dir.'/'.$_.'.pl'; |
20 |
my @cmd = ('perl', map ({"-I$_"} @INC), |
21 |
'domtest2perl.pl', $dir.'/'.$_, |
22 |
'--output-file' => $out_file); |
23 |
print STDERR join " ", @cmd, "\n"; |
24 |
system @cmd and die "$0: domtest2perl.pl: $@"; |
25 |
system 'perl', map ({"-I$_"} @INC), '-c', $out_file |
26 |
and die "$0: $out_file: $@"; |
27 |
} |