Commit | Line | Data |
---|---|---|
398f002c NC |
1 | #!./perl -w |
2 | ||
b8ca42e1 | 3 | # Test the well-formed-ness of the MANIFEST file. |
398f002c NC |
4 | |
5 | BEGIN { | |
18388fdb | 6 | @INC = '..' if -f '../TestInit.pm'; |
398f002c | 7 | } |
ac976f88 | 8 | use TestInit qw(T); # T is chdir to the top level |
398f002c | 9 | |
18388fdb | 10 | require 't/test.pl'; |
398f002c | 11 | |
398f002c NC |
12 | plan('no_plan'); |
13 | ||
18388fdb | 14 | my $manifest = 'MANIFEST'; |
398f002c NC |
15 | |
16 | open my $m, '<', $manifest or die "Can't open '$manifest': $!"; | |
dcab73c9 | 17 | my @files; |
b8ca42e1 | 18 | # Test that MANIFEST uses tabs - not spaces - after the name of the file. |
398f002c NC |
19 | while (<$m>) { |
20 | chomp; | |
dcab73c9 YO |
21 | unless( /\s/ ) { |
22 | push @files, $_; | |
23 | # no need for further tests on lines without whitespace (i.e., filename only) | |
24 | next; | |
25 | } | |
4e86fc4b | 26 | my ($file, $separator) = /^(\S+)(\s+)/; |
dcab73c9 YO |
27 | push @files, $file; |
28 | ||
398f002c | 29 | isnt($file, undef, "Line $. doesn't start with a blank") or next; |
18388fdb | 30 | ok(-f $file, "File $file exists"); |
4e86fc4b | 31 | if ($separator !~ tr/\t//c) { |
398f002c NC |
32 | # It's all tabs |
33 | next; | |
34 | } elsif ($separator !~ tr/ //c) { | |
35 | # It's all spaces | |
36 | fail("Spaces in entry for $file"); | |
398f002c NC |
37 | } elsif ($separator =~ tr/\t//) { |
38 | fail("Mixed tabs and spaces in entry for $file"); | |
39 | } else { | |
40 | fail("Odd whitespace in entry for $file"); | |
41 | } | |
42 | } | |
43 | ||
44 | close $m or die $!; | |
45 | ||
4e86fc4b JH |
46 | # Test that MANIFEST is properly sorted |
47 | SKIP: { | |
18388fdb | 48 | skip("'Porting/manisort' not found", 1) if (! -f 'Porting/manisort'); |
4e86fc4b | 49 | |
18388fdb NC |
50 | my $result = runperl('progfile' => 'Porting/manisort', |
51 | 'args' => [ '-c', $manifest ], | |
4e86fc4b JH |
52 | 'stderr' => 1); |
53 | ||
54 | like($result, qr/is sorted properly/, 'MANIFEST sorted properly'); | |
55 | } | |
b8ca42e1 | 56 | |
dcab73c9 | 57 | SKIP: { |
7cadc1d0 | 58 | find_git_or_skip(6); |
dcab73c9 YO |
59 | chomp(my @repo= grep { !/\.gitignore$/ } `git ls-files`); |
60 | skip("git ls-files didnt work",3) | |
61 | if !@repo; | |
917bb0fa | 62 | is( 0+@repo, 0+@files, "git ls-files gives the same number of files as MANIFEST lists"); |
dcab73c9 YO |
63 | my %repo= map { $_ => 1 } @repo; |
64 | my %mani= map { $_ => 1 } @files; | |
65 | is( 0+keys %mani, 0+@files, "no duplicate files in MANIFEST"); | |
66 | delete $mani{$_} for @repo; | |
67 | delete $repo{$_} for @files; | |
68 | my @not_in_mani= keys %repo; | |
69 | my @still_in_mani= keys %mani; | |
70 | ||
71 | is( 0+@not_in_mani, 0, "Nothing added to the repo that isn't in MANIFEST"); | |
72 | is( "not in MANIFEST: @not_in_mani", "not in MANIFEST: ", | |
73 | "Nothing added to the repo that isn't in MANIFEST"); | |
74 | is( 0+@still_in_mani, 0, "Nothing in the MANIFEST that isn't tracked by git"); | |
75 | is( "should not be in MANIFEST: @still_in_mani", "should not be in MANIFEST: ", | |
76 | "Nothing in the MANIFEST that isn't tracked by git"); | |
77 | ||
78 | } | |
79 | ||
b8ca42e1 | 80 | # EOF |