Commit | Line | Data |
---|---|---|
f52c37b4 NC |
1 | #!./perl -w |
2 | ||
3 | =head1 filenames.t | |
4 | ||
5 | Test the well-formed-ness of filenames names in the MANIFEST file. Current | |
6 | tests being done: | |
7 | ||
8 | =over 4 | |
9 | ||
10 | =item * no more than 39 characters before the dot, and 39 after | |
11 | ||
12 | =item * no filenames starting with - | |
13 | ||
14 | =item * don't use any of these names (regardless of case) before the dot: CON, | |
15 | PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, | |
16 | LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9 | |
17 | ||
18 | =item * no spaces, ( or & in filenames | |
19 | ||
20 | =back | |
21 | ||
22 | =cut | |
23 | ||
24 | BEGIN { | |
25 | chdir 't'; | |
26 | @INC = '../lib'; | |
27 | } | |
28 | ||
29 | use strict; | |
f52c37b4 NC |
30 | use File::Basename; |
31 | require './test.pl'; | |
32 | ||
f52c37b4 | 33 | |
3013c637 | 34 | my $manifest = '../MANIFEST'; |
f52c37b4 | 35 | |
f52c37b4 NC |
36 | open my $m, '<', $manifest or die "Can't open '$manifest': $!"; |
37 | my @files; | |
38 | while (<$m>) { | |
39 | chomp; | |
40 | my($path) = split /\t+/; | |
c4c1a999 | 41 | push @files, $path; |
f52c37b4 | 42 | |
f52c37b4 NC |
43 | } |
44 | close $m or die $!; | |
45 | ||
c4c1a999 DM |
46 | plan(scalar @files); |
47 | ||
3013c637 NC |
48 | PATHNAME: for my $pathname (@files) { |
49 | my @path_components = split('/',$pathname); | |
50 | my $filename = pop @path_components; | |
43922be2 | 51 | for my $component (@path_components) { |
3013c637 NC |
52 | if ($component =~ /\./) { |
53 | fail("$pathname has directory components containing '.'"); | |
54 | next PATHNAME; | |
55 | } | |
56 | if (length $component > 32) { | |
57 | fail("$pathname has a name over 32 characters (VOS requirement)"); | |
58 | next PATHNAME; | |
59 | } | |
43922be2 JV |
60 | } |
61 | ||
62 | ||
c4c1a999 | 63 | if ($filename =~ /^\-/) { |
3013c637 NC |
64 | fail("$pathname starts with -"); |
65 | next PATHNAME; | |
c4c1a999 | 66 | } |
f52c37b4 NC |
67 | |
68 | my($before, $after) = split /\./, $filename; | |
c4c1a999 | 69 | if (length $before > 39) { |
3013c637 NC |
70 | fail("$pathname has more than 39 characters before the dot"); |
71 | } elsif ($after && length $after > 39) { | |
72 | fail("$pathname has more than 39 characters after the dot"); | |
73 | } elsif ($filename =~ /^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])\./i) { | |
74 | fail("$pathname has a reserved name"); | |
75 | } elsif ($filename =~ /\s|\(|\&/) { | |
76 | fail("$pathname has a reserved character"); | |
77 | } else { | |
78 | pass("$pathname ok"); | |
c4c1a999 | 79 | } |
f52c37b4 NC |
80 | } |
81 | ||
82 | # EOF |