From f5e7a2d44186c944c53de6e52bfde9e08aa5181e Mon Sep 17 00:00:00 2001 From: Axel Beckert Date: Fri, 23 Oct 2020 14:41:31 +0200 Subject: [PATCH] Fix no-tabs.t failing on Travis CI: Replace all_perl_files_ok() --- xt/no-tabs.t | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/xt/no-tabs.t b/xt/no-tabs.t index 3df9ad3..4c7ccb6 100755 --- a/xt/no-tabs.t +++ b/xt/no-tabs.t @@ -9,11 +9,9 @@ use strict; use File::Find; +use Test::More; use Test::NoTabs; -# Check all Perl files -all_perl_files_ok(); - # # Find all the files beneath the current directory, # and call 'checkFile' with the name. @@ -54,25 +52,36 @@ sub checkFile my $isShell = 0; my $isPerl = 0; - # Read the file. - open( INPUT, "<", $file ); - foreach my $line ( ) - { - if ( ( $line =~ /\/bin\/sh/ ) || - ( $line =~ /\/bin\/bash/ ) ) + + if ( $file =~ /\.sh$/ ) { + $isShell = 1; + } elsif ( $file =~ /\.(pl|pm|t)$/ ) { + $isPerl = 1; + } else { + + # Read the file. + open( INPUT, "<", $file ); + foreach my $line ( ) { - $isShell = 1; - last; - } - if ( $line =~ /\/usr\/bin\/perl/ ) - { - last; + if ( ( $line =~ /^#! *\/bin\/sh/ ) || + ( $line =~ /^#! *\/bin\/bash/ ) ) + { + $isShell = 1; + last; + } + if ( $line =~ /^#!.*\bperl\b/ ) + { + $isPerl = 1; + last; + } } + close( INPUT ); } - close( INPUT ); # # Run check if it is a shell file. # - notabs_ok( $file ) if $isShell; + notabs_ok( $file ) if $isShell or $isPerl; } + +done_testing();