Commit | Line | Data |
---|---|---|
ff906f87 DG |
1 | #!/perl -w |
2 | use 5.010; | |
3 | use strict; | |
3a73a075 | 4 | use Config; |
ff906f87 DG |
5 | |
6 | # This test checks that anything with an executable bit is | |
7 | # identified in Porting/exec-bit.txt to makerel will set | |
8 | # the exe bit in the release tarball | |
67f552ad S |
9 | # and that anything with an executable bit also has a shebang |
10 | ||
11 | sub has_shebang { | |
12 | my $fname = shift; | |
13 | open my $fh, '<', $fname or die "Can't open '$fname': $!"; | |
14 | my $line = <$fh>; | |
15 | close $fh; | |
16 | ||
17 | return $line =~ /^\#!\s*([A-Za-z0-9_\-\/\.])+\s?/ ? 1 : 0; | |
18 | } | |
ff906f87 DG |
19 | |
20 | require './test.pl'; | |
936fbabe GG |
21 | if ( $^O eq "MSWin32" ) { |
22 | skip_all( "-x on MSWin32 only indicates file has executable suffix. Try Cygwin?" ); | |
48b7c141 | 23 | } |
ff906f87 | 24 | |
bffed04b CB |
25 | if ( $^O eq "VMS" ) { |
26 | skip_all( "Filename case may not be preserved and other porting issues." ); | |
27 | } | |
28 | ||
f6dacdca PG |
29 | if ( $^O eq "vos" ) { |
30 | skip_all( "VOS combines the read and execute permission bits." ); | |
31 | } | |
32 | ||
3a73a075 BF |
33 | if ( $Config{usecrosscompile} ) { |
34 | skip_all( "Not all files are available during cross-compilation" ); | |
35 | } | |
36 | ||
ff906f87 DG |
37 | plan('no_plan'); |
38 | ||
39 | use ExtUtils::Manifest qw(maniread); | |
ff906f87 DG |
40 | |
41 | # Copied from Porting/makerel - these will get +x in the tarball | |
42 | # XXX refactor? -- dagolden, 2010-07-23 | |
75b4b7ae | 43 | my %exe_list = |
ff906f87 | 44 | map { $_ => 1 } |
75b4b7ae | 45 | map { my ($f) = split; glob("../$f") } |
ff906f87 DG |
46 | grep { $_ !~ /\A#/ && $_ !~ /\A\s*\z/ } |
47 | map { split "\n" } | |
48 | do { local (@ARGV, $/) = '../Porting/exec-bit.txt'; <> }; | |
49 | ||
50 | # Get MANIFEST | |
51 | $ExtUtils::Manifest::Quiet = 1; | |
52 | my @manifest = sort keys %{ maniread("../MANIFEST") }; | |
53 | ||
54 | # Check that +x files in repo get +x from makerel | |
75b4b7ae FR |
55 | for my $f ( map { "../$_" } @manifest ) { |
56 | next unless -x $f; | |
ff906f87 | 57 | |
67f552ad S |
58 | ok( has_shebang($f), "File $f has shebang" ); |
59 | ||
ff906f87 | 60 | ok( $exe_list{$f}, "tarball will chmod +x $f" ) |
63dccf30 | 61 | or diag( "Remove the exec bit or add '$f' to Porting/exec-bit.txt" ); |
ff906f87 DG |
62 | |
63 | delete $exe_list{$f}; # seen it | |
64 | } | |
65 | ||
66 | ok( ! %exe_list, "Everything in Porting/exec-bit.txt has +x in repo" ) | |
67 | or diag( "Files missing exec bit:\n " . join("\n ", sort keys %exe_list) . "\n"); |