ok 1 => pass; ok 0 => fail and report the path in the test
[lhc/web/wiklou.git] / t / maint / php-lint.t
1 #!/usr/bin/env perl
2 #
3 # Based on php-tag.t and eol-style
4 #
5 use strict;
6 use warnings;
7
8 use Test::More;
9 use File::Find;
10 use IPC::Open3;
11 use File::Spec;
12 use Symbol qw(gensym);
13
14 my $ext = qr/(?: php | inc )/x;
15 my @files;
16
17 find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );
18
19 plan tests => scalar @files ;
20
21 for my $file (@files) {
22 open NULL, '+>', File::Spec->devnull and \*NULL or die;
23 my $pid = open3('<&NULL', \*P, '>&NULL', qw'php -l', $file);
24 my $res = do { local $/; <P> . "" };
25 chomp $res;
26 waitpid $pid, 0;
27
28 if ( $? == 0 ) {
29 pass($file);
30 } else {
31 fail("$file does not pass php -l. Error was: $res");
32 }
33 }