This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
skip a Tets-Simple test that's leaking shm blocks
[perl5.git] / t / porting / filenames.t
CommitLineData
f52c37b4
NC
1#!./perl -w
2
3=head1 filenames.t
4
5Test the well-formed-ness of filenames names in the MANIFEST file. Current
6tests 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,
15PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1,
16LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9
17
18=item * no spaces, ( or & in filenames
19
20=back
21
22=cut
23
24BEGIN {
25 chdir 't';
26 @INC = '../lib';
27}
28
29use strict;
f52c37b4
NC
30use File::Basename;
31require './test.pl';
32
f52c37b4 33
3013c637 34my $manifest = '../MANIFEST';
f52c37b4 35
f52c37b4
NC
36open my $m, '<', $manifest or die "Can't open '$manifest': $!";
37my @files;
38while (<$m>) {
39 chomp;
40 my($path) = split /\t+/;
c4c1a999 41 push @files, $path;
f52c37b4 42
f52c37b4
NC
43}
44close $m or die $!;
45
c4c1a999
DM
46plan(scalar @files);
47
3013c637
NC
48PATHNAME: 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