2 # Copyright (C) 2006-2009, Parrot Foundation.
8 use lib qw( . lib ../lib ../../lib );
10 use ExtUtils::Manifest qw(maniread);
11 use Parrot::Distribution;
14 # set up how many tests to run
19 t/codingstd/filenames.t - checks that filenames conform to standards
24 % prove t/codingstd/filenames.t
27 % perl t/codingstd/filenames.t src/foo.c include/parrot/bar.h
31 Checks that the filenames used for files within the Parrot distribution
32 conform to a set of highly portable standards.
36 =item No multiple dots within filenames
38 Files with more than one dot ( '.' ) in their filename are problematic on
39 some platforms (e.g. VMS) hence avoid these in Parrot.
41 =item No strange characters in filenames
43 Filenames are restricted to the characters C<a-zA-Z0-9_-.>
45 =item Filenames length restriction
47 Filenames are restricted to 32 characters.
53 L<docs/pdds/pdd07_codingstd.pod>
57 Paul Cochrane <paultcochrane at gmail dot com>
61 my $DIST = Parrot::Distribution->new;
67 my $manifest = maniread('MANIFEST');
68 # Give ports a little more leeway
69 @files = grep {! /^ports/} sort keys %$manifest;
71 my ( @multi_dots, @strange_chars, @too_long );
73 foreach my $file ( @files ) {
75 # check for multiple dots in filenames
76 my $num_dots = grep(m/\./g, split( m//, $file));
77 if ( $num_dots > 1 ) {
78 push @multi_dots, $file . "\n";
81 # check the characters used in filenames
82 push @strange_chars, $file . "\n"
83 if $file =~ m/[^\w\/.\-]/g;
85 # check for filenames that are too long
86 my ($volume, $directory, $filename) = File::Spec->splitpath( $file );
87 my @filename_chars = split m//, $filename;
88 my $filename_len = scalar @filename_chars;
89 push @too_long, $file . ":$filename_len chars\n"
90 if $filename_len > 32;
94 ok( !@multi_dots, 'No multi-dot filenames' )
95 or diag( "Multi-dot filename found in " . @multi_dots
96 . " files:\n@multi_dots" );
98 ok( !@strange_chars, 'Portable characters in filenames' )
99 or diag( "Filename with non-portable character found in "
100 . @strange_chars . " files:\n@strange_chars" );
102 ok( !@too_long, 'Filenames length' )
103 or diag( "Filename with more than 32 chars found in "
104 . @too_long . " files:\n@too_long" );
108 # cperl-indent-level: 4
111 # vim: expandtab shiftwidth=4: