4 # This tests the well-formed-ness of the MANIFEST file.
9 # It's broken - how do I fix it?
10 # If MANIFEST is not sorted properly, you will get this error output:
11 # got ''MANIFEST' is NOT sorted properly
13 # # expected /(?^:is sorted properly)/
15 # To correct this, run either:
17 # ./perl -Ilib Porting/manisort -o MANIFEST MANIFEST
19 # which will output "'MANIFEST' is NOT sorted properly" but which will
20 # correct the problem; or:
24 # which will output "WARNING: re-sorting MANIFEST" but which will also
25 # correct the problem.
29 @INC = '..' if -f '../TestInit.pm';
31 use TestInit qw(T); # T is chdir to the top level
35 skip_all("Cross-compiling, the entire source might not be available")
36 if $Config{usecrosscompile};
41 my $manifest = 'MANIFEST';
43 open my $m, '<', $manifest or die "Can't open '$manifest': $!";
45 # Test that MANIFEST uses tabs - not spaces - after the name of the file.
50 # no need for further tests on lines without whitespace (i.e., filename only)
53 my ($file, $separator) = /^(\S+)(\s+)/;
56 isnt($file, undef, "Line $. doesn't start with a blank") or next;
57 ok(-f $file, "File $file exists");
58 if ($separator !~ tr/\t//c) {
61 } elsif ($separator !~ tr/ //c) {
63 fail("Spaces in entry for $file");
64 } elsif ($separator =~ tr/\t//) {
65 fail("Mixed tabs and spaces in entry for $file");
67 fail("Odd whitespace in entry for $file");
73 # Test that MANIFEST is properly sorted
75 skip("Sorting order is different under EBCDIC", 1) if $::IS_EBCDIC || $::IS_EBCDIC;
76 skip("'Porting/manisort' not found", 1) if (! -f 'Porting/manisort');
78 my $result = runperl('progfile' => 'Porting/manisort',
79 'args' => [ '-c', $manifest ],
83 like($result, qr/is sorted properly/, 'MANIFEST sorted properly');
88 chomp(my @repo= grep { !/\.gitignore$/ } `git ls-files`);
89 skip("git ls-files didnt work",3)
91 is( 0+@repo, 0+@files, "git ls-files gives the same number of files as MANIFEST lists");
93 ++$repo{$_} for @repo;
95 ++$mani{$_} for @files;
96 is( 0+keys %mani, 0+@files, "no duplicate files in MANIFEST")
97 or diag(join("\n ", "Duplicates:",grep $mani{$_} > 1, keys %mani));
98 delete $mani{$_} for @repo;
99 delete $repo{$_} for @files;
100 my @not_in_mani= keys %repo;
101 my @still_in_mani= keys %mani;
103 is( 0+@not_in_mani, 0, "Nothing added to the repo that isn't in MANIFEST");
104 is( "not in MANIFEST: @not_in_mani", "not in MANIFEST: ",
105 "Nothing added to the repo that isn't in MANIFEST");
106 is( 0+@still_in_mani, 0, "Nothing in the MANIFEST that isn't tracked by git");
107 is( "should not be in MANIFEST: @still_in_mani", "should not be in MANIFEST: ",
108 "Nothing in the MANIFEST that isn't tracked by git");