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