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) {
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