Add MANIFEST sort test
authorJerry D. Hedden <jdhedden@cpan.org>
Wed, 29 Jul 2009 17:47:53 +0000 (13:47 -0400)
committerNicholas Clark <nick@ccl4.org>
Wed, 29 Jul 2009 18:00:51 +0000 (19:00 +0100)
t/lib/manifest.t

index a98e974..ea40708 100644 (file)
@@ -1,7 +1,6 @@
 #!./perl -w
 
-# Test the well formed-ness of the MANIFEST file.
-# For now, just test that it uses tabs not spaces after the name of the file.
+# Test the well-formed-ness of the MANIFEST file.
 
 BEGIN {
     chdir 't';
@@ -12,17 +11,16 @@ use strict;
 use File::Spec;
 require './test.pl';
 
-my $failed = 0;
-
 plan('no_plan');
 
 my $manifest = File::Spec->catfile(File::Spec->updir(), 'MANIFEST');
 
 open my $m, '<', $manifest or die "Can't open '$manifest': $!";
 
+# Test that MANIFEST uses tabs - not spaces - after the name of the file.
 while (<$m>) {
     chomp;
-    next unless /\s/;
+    next unless /\s/;   # Ignore lines without whitespace (i.e., filename only)
     my ($file, $separator) = /^(\S+)(\s+)/;
     isnt($file, undef, "Line $. doesn't start with a blank") or next;
     if ($separator !~ tr/\t//c) {
@@ -31,7 +29,6 @@ while (<$m>) {
     } elsif ($separator !~ tr/ //c) {
        # It's all spaces
        fail("Spaces in entry for $file");
-       next;
     } elsif ($separator =~ tr/\t//) {
        fail("Mixed tabs and spaces in entry for $file");
     } else {
@@ -41,4 +38,8 @@ while (<$m>) {
 
 close $m or die $!;
 
-is($failed, 0, 'All lines are good');
+# Test that MANIFEST is properly sorted
+my $sorted = `LC_ALL=C sort -fdc $manifest 2>&1`;
+is($sorted, '', 'MANIFEST properly sorted');
+
+# EOF