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