Bug 18055: Speed up '00-strict.t' test, with Parallel::ForkManager
[koha.git] / t / db_dependent / 00-strict.t
1 #!/usr/bin/perl
2 # This script is called by the pre-commit git hook to test modules compile
3
4 use strict;
5 use warnings;
6
7 use threads;    # used for parallel
8 use Test::More;
9 use Test::Strict;
10 use Parallel::ForkManager;
11 use Sys::CPU;
12
13 use lib("misc/translator");
14 use lib("installer");
15
16 my @dirs = (
17     'acqui',             'admin',
18     'authorities',       'basket',
19     'catalogue',         'cataloguing',
20     'changelanguage.pl', 'circ',
21     'debian',            'docs',
22     'edithelp.pl',       'errors',
23     'fix-perl-path.PL',  'help.pl',
24     'installer',         'koha_perl_deps.pl',
25     'kohaversion.pl',    'labels',
26     'mainpage.pl',       'Makefile.PL',
27     'members',           'misc',
28     'offline_circ',      'opac',
29     'patroncards',       'reports',
30     'reserve',           'reviews',
31     'rewrite-config.PL', 'rotating_collections',
32     'serials',           'services',
33     'skel',              'suggestion',
34     'svc',               'tags',
35     'tools',             'virtualshelves'
36 );
37
38 $Test::Strict::TEST_STRICT = 0;
39 $Test::Strict::TEST_SKIP = [ 'misc/kohalib.pl', 'misc/plack/koha.psgi' ];
40
41 my $ncpu;
42 if ( $ENV{KOHA_JENKINS} ) {
43     $ncpu = 2; # works fastest on kc.org jenkins box
44 } else {
45     $ncpu = Sys::CPU::cpu_count();
46 }
47
48 my $pm   = new Parallel::ForkManager($ncpu);
49
50 foreach my $d (@dirs) {
51     $pm->start and next;    # do the fork
52
53     all_perl_files_ok($d);
54
55     $pm->finish;            # do the exit in the child process
56 }
57
58 $pm->wait_all_children;
59
60 done_testing();