1
0
mirror of synced 2026-05-02 14:40:09 +00:00

2006-06-10 20:45:10 by steve

Added perl syntax check for each perl file we ship.  Hopefully this
 will catch simple errors like the stupid broken shell script hook we
 left in v1.6
This commit is contained in:
steve
2006-06-10 20:45:10 +00:00
parent bd470289e2
commit b14f4b9ebc

66
tests/perl-syntax.t Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/perl -w
#
# Test that every perl file we have passes the syntax check.
#
# Steve
# --
# $Id: perl-syntax.t,v 1.1 2006-06-10 20:45:10 steve Exp $
use strict;
use File::Find;
use Test::More qw( no_plan );
#
# Find all the files beneath the current directory,
# and call 'checkFile' with the name.
#
find( { wanted => \&checkFile, no_chdir => 1 }, '.' );
#
# Check a file.
#
# If this is a perl file then call "perl -c $name", otherwise
# return
#
sub checkFile
{
# The file.
my $file = $File::Find::name;
# We don't care about directories
return if ( ! -f $file );
# `modules.sh` is a false positive.
return if ( $file =~ /modules.sh$/ );
# See if it is a perl file.
my $isPerl = 0;
# Read the file.
open( INPUT, "<", $file );
foreach my $line ( <INPUT> )
{
if ( $line =~ /\/usr\/bin\/perl/ )
{
$isPerl = 1;
}
}
close( INPUT );
#
# Return if it wasn't a perl file.
#
return if ( ! $isPerl );
#
# Now run 'perl -c $file' to see if we pass the syntax
# check
#
my $retval = system( "perl -c $file 2>/dev/null >/dev/null" );
is( $retval, 0, "Perl file passes our syntax check: $file" );
}