1
0
mirror of synced 2026-04-07 05:26:28 +00:00

Fix no-tabs.t failing on Travis CI: Replace all_perl_files_ok()

This commit is contained in:
Axel Beckert
2020-10-23 14:41:31 +02:00
parent 79650b9d70
commit f5e7a2d441

View File

@@ -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 ( <INPUT> )
{
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 ( <INPUT> )
{
$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();