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
index aa09ac8..1deb376 100644 (file)
@@ -5,21 +5,39 @@ use strict;
 # This test checks that anything with an executable bit is
 # identified in Porting/exec-bit.txt to makerel will set
 # the exe bit in the release tarball
+# and that anything with an executable bit also has a shebang
+
+sub has_shebang {
+  my $fname = shift;
+  open my $fh, '<', $fname or die "Can't open '$fname': $!";
+  my $line = <$fh>;
+  close $fh;
+
+  return $line =~ /^\#!\s*([A-Za-z0-9_\-\/\.])+\s?/ ? 1 : 0;
+}
 
 require './test.pl';
+if ( $^O eq "MSWin32" ) {
+  skip_all( "-x on MSWin32 only indicates file has executable suffix. Try Cygwin?" );
+}
+
+if ( $^O eq "VMS" ) {
+  skip_all( "Filename case may not be preserved and other porting issues." );
+}
+
+if ( $^O eq "vos" ) {
+  skip_all( "VOS combines the read and execute permission bits." );
+}
 
 plan('no_plan');
 
 use ExtUtils::Manifest qw(maniread);
-use File::Basename;
-use File::Find;
-use File::Spec::Functions;
 
 # Copied from Porting/makerel - these will get +x in the tarball
 # XXX refactor? -- dagolden, 2010-07-23
-my %exe_list = 
+my %exe_list =
   map   { $_ => 1 }
-  map   { my ($f) = split; glob($f) } 
+  map   { my ($f) = split; glob("../$f") }
   grep  { $_ !~ /\A#/ && $_ !~ /\A\s*\z/ }
   map   { split "\n" }
   do    { local (@ARGV, $/) = '../Porting/exec-bit.txt'; <> };
@@ -29,8 +47,10 @@ $ExtUtils::Manifest::Quiet = 1;
 my @manifest = sort keys %{ maniread("../MANIFEST") };
 
 # Check that +x files in repo get +x from makerel
-for my $f ( @manifest ) {
-  next unless -x "../$f";
+for my $f ( map { "../$_" } @manifest ) {
+  next unless -x $f;
+
+  ok( has_shebang($f), "File $f has shebang" );
 
   ok( $exe_list{$f}, "tarball will chmod +x $f" )
     or diag( "Remove the exec bit or add '$f' to Porting/exec-bit.txt" );
@@ -40,4 +60,3 @@ for my $f ( @manifest ) {
 
 ok( ! %exe_list, "Everything in Porting/exec-bit.txt has +x in repo" )
   or diag( "Files missing exec bit:\n  " . join("\n  ", sort keys %exe_list) . "\n");
-