From: Jarkko Hietaniemi Date: Mon, 28 Jan 2002 13:36:15 +0000 (+0000) Subject: The "used only once" warnings (from gv_check) come X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=247c8d761ac3d8c85bd20779e586fcf0bebd9de9;p=p5sagit%2Fp5-mst-13.2.git The "used only once" warnings (from gv_check) come in pseudorandom hash order-- in EBCDIC the order is different. Add a new option that allow the warnings to come in any order (Paul Marquess). p4raw-id: //depot/perl@14465 --- diff --git a/lib/warnings.t b/lib/warnings.t index c88a4d9..009dee0 100644 --- a/lib/warnings.t +++ b/lib/warnings.t @@ -119,18 +119,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/) || @@ -144,3 +155,15 @@ for (@prgs){ foreach (@temps) { unlink $_ if $_ } } + +sub randomMatch +{ + my $got = shift ; + my $expected = shift; + + my @got = sort split "\n", $got ; + my @expected = sort split "\n", $expected ; + + return "@got" eq "@expected"; + +} diff --git a/t/lib/warnings/perl b/t/lib/warnings/perl index 512ee7f..78d730b 100644 --- a/t/lib/warnings/perl +++ b/t/lib/warnings/perl @@ -46,6 +46,7 @@ $x = 3 ; use warnings 'once' ; $z = 3 ; EXPECT +OPTION random Name "main::z" used only once: possible typo at - line 6. Name "main::x" used only once: possible typo at - line 4. ########