File tree Expand file tree Collapse file tree 1 file changed +38
-26
lines changed Expand file tree Collapse file tree 1 file changed +38
-26
lines changed Original file line number Diff line number Diff line change 1
1
# !/usr/bin/perl -w
2
2
#
3
- # Copyright (C) 2010 , Nick Andrew <nick@nick-andrew.net>
4
- # Licensed under the terms of the GNU General Public License, Version 3
3
+ # Copyright (C) 2014 , Nick Andrew <nick@nick-andrew.net>
4
+ # Licensed under the terms of the GNU General Public License, Version 3
5
5
#
6
- # Syntax-check all modules and scripts
6
+ # Syntax-check all modules, scripts and test scripts
7
+
8
+ use strict;
9
+ use warnings;
7
10
8
11
use Test::More qw( no_plan) ;
9
12
10
- checkDir(' lib' );
11
- checkDir(' bin' );
12
- checkDir(' scripts' );
13
+ test_dir(' bin' );
14
+ test_dir(' lib' );
15
+ test_dir(' perllib' );
16
+ test_dir(' scripts' );
17
+ test_dir(' t' );
13
18
14
19
exit (0);
15
20
16
- sub checkDir {
21
+ sub test_dir {
17
22
my ($dir ) = @_ ;
18
23
19
24
if (! -d $dir ) {
@@ -30,26 +35,33 @@ sub checkDir {
30
35
foreach my $f (@files ) {
31
36
my $path = " $dir /$f " ;
32
37
33
- if (-f $path && $f =~ / \. (pl|pm|t)$ / ) {
34
- open (P, " perl -Mstrict -wc $path 2>&1 |" );
35
- my $lines ;
36
- while (<P>) {
37
- $lines .= $_ ;
38
- }
39
- if (! close (P)) {
40
- warn " Error closing pipe from perl syntax check $path " ;
41
- }
42
- my $rc = $? ;
43
-
44
- if ($rc ) {
45
- diag($lines );
46
- fail(" $path failed - code $rc " );
47
- } else {
48
- pass($path );
49
- }
38
+ if (-d $path ) {
39
+ test_dir($path );
50
40
}
51
- elsif (-d $path ) {
52
- checkDir ($path );
41
+ elsif (-f $path && $f =~ / \. (pl|pm|t) $ / ) {
42
+ test_file ($path );
53
43
}
54
44
}
55
45
}
46
+
47
+ sub test_file {
48
+ my ($path ) = @_ ;
49
+
50
+ open (P, " perl -Mstrict -wc $path 2>&1 |" );
51
+ my $lines ;
52
+
53
+ while (<P>) {
54
+ $lines .= $_ ;
55
+ }
56
+
57
+ close (P);
58
+
59
+ my $rc = $? ;
60
+
61
+ if ($rc ) {
62
+ diag($lines );
63
+ fail(" $path failed - code $rc " );
64
+ } else {
65
+ pass($path );
66
+ }
67
+ }
You can’t perform that action at this time.
0 commit comments