From beca89999e82732430a8632228be3b5c363d39e0 Mon Sep 17 00:00:00 2001 From: Stig Sandbeck Mathisen Date: Sun, 5 Oct 2014 00:17:23 +0200 Subject: [PATCH] Handle perl -T checks --- t/test.t | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/t/test.t b/t/test.t index 50010787..80316e95 100644 --- a/t/test.t +++ b/t/test.t @@ -14,13 +14,14 @@ use vars qw/*name *dir *prune/; my $num_plugins = 0; sub wanted { - my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter ); + my ( $dev, $ino, $mode, $nlink, $uid, $gid, $interpreter, $arguments ); ( ( $dev, $ino, $mode, $nlink, $uid, $gid ) = lstat($_) ) && -f _ - && ( $interpreter = hashbang("$_") ) + && ( ( $interpreter, $arguments ) = hashbang("$_") ) + && ($interpreter) && ++$num_plugins - && process_file( $_, $name, $interpreter ); + && process_file( $_, $name, $interpreter, $arguments ); } File::Find::find( { wanted => \&wanted }, 'plugins' ); @@ -31,17 +32,20 @@ sub hashbang { my $firstline = <$file>; close $file; - $firstline =~ m{ ^\#! # hashbang - \s* # optional space - (?:/usr/bin/env\s+)? # optional /usr/bin/env - (?\S+) # interpreter - }xm; + $firstline =~ m{ ^\#! # hashbang + \s* # optional space + (?:/usr/bin/env\s+)? # optional /usr/bin/env + (?\S+) # interpreter + (?:\s+ + (?[^\n]*) # optional interpreter arguments + )? + }xms; - return $+{interpreter}; + return ($+{interpreter}, $+{arguments}); } sub process_file { - my ( $file, $filename, $interpreter ) = @_; + my ( $file, $filename, $interpreter, $arguments ) = @_; use v5.10.1; if ( $interpreter =~ m{/bin/sh} ) { @@ -76,8 +80,15 @@ sub process_file { ); } elsif ( $interpreter =~ m{perl} ) { + my $command; + if ($arguments =~ m{-.*T}mx) { + $command = [ 'perl', '-cwT', $file ]; + } + else { + $command = [ 'perl', '-cw', $file ]; + } run_check( - { command => [ 'perl', '-cw', $file ], + { command => $command, description => 'perl syntax check', filename => $filename }