File: perl_syntax_check.t

package info (click to toggle)
pkg-kde-tools 0.20.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 916 kB
  • sloc: perl: 4,238; python: 686; ansic: 628; sh: 441; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 655 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use Test::More;
use File::Find;

my @files;

# Find all perl modules
find(sub { push @files, $File::Find::name if /\.pm$/ }, "perllib", "datalib");

# Find all perl executables in the top level
foreach my $file (glob('*')) {
    if (-f $file && -x $file) {
        open(my $fh, "<", $file) or die "Unable to open $file for reading";
        my $line = <$fh>;
        if ($line =~ /^#!.*\/perl$/) {
            push @files, $file;
        }
        close($fh);
    }
}

# Setup a plan
plan tests => scalar(@files);

foreach my $file (@files) {
    isnt(system("LANG=C $^X -c $file 2>&1 | grep -v 'syntax OK\$' >&2"), 0,
        "Syntax check of $file");
}