/[suikacvs]/messaging/manakai/bin/domts2perl.pl
Suika

Diff of /messaging/manakai/bin/domts2perl.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sun Oct 10 06:09:47 2004 UTC revision 1.5 by wakaba, Thu Oct 6 10:53:34 2005 UTC
# Line 5  use Getopt::Long; Line 5  use Getopt::Long;
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    my %Opt = (
10      test2perl_option => [],
11    );
12  GetOptions (  GetOptions (
13      'domtest2perl-option=s' => sub {
14        shift;
15        push @{$Opt{test2perl_option}}, shift;
16      },
17      'domtest2perl-path=s' => \$domtest2perl,
18    'test-directory=s' => \$dir,    'test-directory=s' => \$dir,
19    'test-file-pattern=s' => \$file_pattern,    'test-file-pattern=s' => \$file_pattern,
20    'output-directory=s' => \$out_dir,    'output-directory=s' => \$out_dir,
21  );  ) or die;
22  $dir or die "$0: test-directory must be specified";  $dir or die "$0: test-directory must be specified";
23  $out_dir or die "$0: output-directory must be specified";  $out_dir or die "$0: output-directory must be specified";
24  $file_pattern ||= qr/\.xml$/;  $file_pattern ||= qr/\.xml$/;
25    
26  opendir my $dirh, $dir or die "$0: $dir: $!";  opendir my $dirh, $dir or die "$0: $dir: $!";
27  for (grep {$_ ne 'alltests.xml'} grep /$file_pattern/, readdir $dirh) {  for (grep {$_ ne 'alltests.xml'} grep /$file_pattern/, readdir $dirh) {
28      my $in_file = $dir.'/'.$_;
29      my $out_file = $out_dir.'/'.$_.'.pl';
30      if (-e $out_file and -C $in_file >= -C $out_file) {
31        warn "$_.pl: Skipped - it is newer than source\n";
32        next;
33      }
34    my @cmd = ('perl', map ({"-I$_"} @INC),    my @cmd = ('perl', map ({"-I$_"} @INC),
35               'domtest2perl.pl', $dir.'/'.$_,               $domtest2perl, $in_file,
36               '--output-file' => $out_dir.'/'.$_.'.pl');               '--output-file-name' => $out_file,
37                 @{$Opt{test2perl_option}});
38    print STDERR join " ", @cmd, "\n";    print STDERR join " ", @cmd, "\n";
39    system @cmd and die "$0: domtest2perl.pl: $@";    print STDERR $in_file, "\n";
40      print STDERR '-> ' . $out_file, "\n";
41      system @cmd and die "$0: $domtest2perl: $@";
42      system 'perl', map ({"-I$_"} @INC), '-c', $out_file
43        and die "$0: $out_file: $@";
44  }  }
45    
46    1;
47    
48    __END__
49    
50    =head1 NAME
51    
52    domts2perl - Generates Perl Test Code from DOM Test Suite
53    
54    =head1 SYNOPSIS
55    
56      perl path/to/domts2perl.pl --test-directory=path/to/source/xml/directory/ \
57               --output-directory=path/to/result/pl/directory/ \
58               --domtest2perl=path/to/domts2perl/pl
59    
60    =head1 OPTIONS
61    
62    =over 4
63    
64    =item --domtest2perl=I<path>
65    
66    Path to the F<domtest2perl.pl> to convert each XMl file to Perl code.
67    
68    =item --output-directory=I<path>
69    
70    Path to result Perl code directory.
71    
72    =item --test-directory=I<path>
73    
74    Path to source XML files in the package of the DOM Test Suite.
75    
76    =back
77    
78    =head1 SEE ALSO
79    
80    I<Document Object Model (DOM) Conformance Test Suites>,
81    <http://www.w3.org/DOM/Test/>.
82    
83    F<domtest2perl.pl>
84    
85    =head1 LICENSE
86    
87    Copyright 2004-2005 Wakaba <w@suika.fam.cx>.  All rights reserved.
88    
89    This program is free software; you can redistribute it and/or
90    modify it under the same terms as Perl itself.
91    
92    =cut
93    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24