pod2html: try to be EOL agnostic.
[p5sagit/p5-mst-13.2.git] / lib / warnings.t
index c88a4d9..e61ffbd 100644 (file)
@@ -7,6 +7,8 @@ BEGIN {
     require Config; import Config;
 }
 
+use File::Path;
+
 $| = 1;
 
 my $Is_VMS     = $^O eq 'VMS';
@@ -29,6 +31,7 @@ my $files = 0;
 foreach my $file (@w_files) {
 
     next if $file =~ /(~|\.orig|,v)$/;
+    next if $file =~ /perlio$/ && !$Config{useperlio};
 
     open F, "<$file" or die "Cannot open $file: $!\n" ;
     my $line = 0;
@@ -58,6 +61,7 @@ for (@prgs){
      }
     my $switch = "";
     my @temps = () ;
+    my @temp_path = () ;
     if (s/^\s*-\w+//){
         $switch = $&;
         $switch =~ s/(-\S*[A-Z]\S*)/"$1"/ if $Is_VMS; # protect uc switches
@@ -73,6 +77,10 @@ for (@prgs){
            my $filename = shift @files ;
            my $code = shift @files ;
            push @temps, $filename ;
+           if ($filename =~ m#(.*)/#) {
+                mkpath($1);
+                push(@temp_path, $1);
+           }
            open F, ">$filename" or die "Cannot open $filename: $!\n" ;
            print F $code ;
            close F or die "Cannot close $filename: $!\n";
@@ -119,18 +127,29 @@ for (@prgs){
     my $prefix = ($results =~ s#^PREFIX(\n|$)##) ;
     # any special options? (OPTIONS foo bar zap)
     my $option_regex = 0;
+    my $option_random = 0;
     if ($expected =~ s/^OPTIONS? (.+)\n//) {
        foreach my $option (split(' ', $1)) {
            if ($option eq 'regex') { # allow regular expressions
                $option_regex = 1;
-           } else {
+           } 
+           elsif ($option eq 'random') { # all lines match, but in any order
+               $option_random = 1;
+           }
+           else {
                die "$0: Unknown OPTION '$option'\n";
            }
        }
     }
+    die "$0: can't have OPTION regex and random\n"
+        if $option_regex + option_random > 1;
     if ( $results =~ s/^SKIPPED\n//) {
        print "$results\n" ;
     }
+    elsif ($option_random)
+    {
+        print "not " if !randomMatch($results, $expected);
+    }
     elsif (($prefix  && (( $option_regex && $results !~ /^$expected/) ||
                         (!$option_regex && $results !~ /^\Q$expected/))) or
           (!$prefix && (( $option_regex && $results !~ /^$expected/) ||
@@ -143,4 +162,18 @@ for (@prgs){
     print "ok ", ++$i, "\n";
     foreach (@temps)
        { unlink $_ if $_ }
+    foreach (@temp_path)
+       { rmtree $_ if -d $_ }
+}
+
+sub randomMatch
+{
+    my $got = shift ;
+    my $expected = shift;
+
+    my @got = sort split "\n", $got ;
+    my @expected = sort split "\n", $expected ;
+
+   return "@got" eq "@expected";
+
 }