From: Nicholas Clark Date: Wed, 29 Jul 2009 21:36:33 +0000 (+0100) Subject: Avoid shelling out to an external sort to verify that MANIFEST is sorted. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3d967d9abef744c6fe8f4b6b7434a38c59380228;p=p5sagit%2Fp5-mst-13.2.git Avoid shelling out to an external sort to verify that MANIFEST is sorted. This also lets us report which file(s) are out of order. --- diff --git a/t/lib/manifest.t b/t/lib/manifest.t index ea40708..bbf038a 100644 --- a/t/lib/manifest.t +++ b/t/lib/manifest.t @@ -17,13 +17,30 @@ my $manifest = File::Spec->catfile(File::Spec->updir(), 'MANIFEST'); open my $m, '<', $manifest or die "Can't open '$manifest': $!"; +my $last_seen = ''; +my $sorted = 1; + # Test that MANIFEST uses tabs - not spaces - after the name of the file. while (<$m>) { chomp; - next unless /\s/; # Ignore lines without whitespace (i.e., filename only) - my ($file, $separator) = /^(\S+)(\s+)/; + + my ($file, $separator) = /^(\S+)(\s*)/; isnt($file, undef, "Line $. doesn't start with a blank") or next; - if ($separator !~ tr/\t//c) { + + # Manifest order is "dictionary order, lowercase" for ASCII: + my $normalised = $_; + $normalised =~ tr/A-Z/a-z/; + $normalised =~ s/[^a-z0-9\s]//g; + + if ($normalised le $last_seen) { + fail("Sort order broken by $file"); + undef $sorted; + } + $last_seen = $normalised; + + if (!$separator) { + # Ignore lines without whitespace (i.e., filename only) + } elsif ($separator !~ tr/\t//c) { # It's all tabs next; } elsif ($separator !~ tr/ //c) { @@ -38,8 +55,6 @@ while (<$m>) { close $m or die $!; -# Test that MANIFEST is properly sorted -my $sorted = `LC_ALL=C sort -fdc $manifest 2>&1`; -is($sorted, '', 'MANIFEST properly sorted'); +ok($sorted, 'MANIFEST properly sorted'); # EOF