xref: /openbsd/gnu/usr.bin/perl/t/porting/manifest.t (revision 8932bfb7)
1#!./perl -w
2
3# Test the well-formed-ness of the MANIFEST file.
4
5BEGIN {
6    chdir 't';
7    @INC = '../lib';
8}
9
10use strict;
11use File::Spec;
12require './test.pl';
13
14plan('no_plan');
15
16my $manifest = File::Spec->catfile(File::Spec->updir(), 'MANIFEST');
17
18open my $m, '<', $manifest or die "Can't open '$manifest': $!";
19
20# Test that MANIFEST uses tabs - not spaces - after the name of the file.
21while (<$m>) {
22    chomp;
23    next unless /\s/;   # Ignore lines without whitespace (i.e., filename only)
24    my ($file, $separator) = /^(\S+)(\s+)/;
25    isnt($file, undef, "Line $. doesn't start with a blank") or next;
26    # Remember, we're running from t/
27    ok(-f "../$file", "File $file exists");
28    if ($separator !~ tr/\t//c) {
29	# It's all tabs
30	next;
31    } elsif ($separator !~ tr/ //c) {
32	# It's all spaces
33	fail("Spaces in entry for $file");
34    } elsif ($separator =~ tr/\t//) {
35	fail("Mixed tabs and spaces in entry for $file");
36    } else {
37	fail("Odd whitespace in entry for $file");
38    }
39}
40
41close $m or die $!;
42
43# Test that MANIFEST is properly sorted
44SKIP: {
45    skip("'Porting/manisort' not found", 1) if (! -f '../Porting/manisort');
46
47    my $result = runperl('progfile' => '../Porting/manisort',
48                         'args'     => [ '-c', '../MANIFEST' ],
49                         'stderr'   => 1);
50
51    like($result, qr/is sorted properly/, 'MANIFEST sorted properly');
52}
53
54# EOF
55