Test plan:
Confirm than prove xt/author/valid-templates.t is quicker with this
patch.
Before I got:
Files=1, Tests=840, 21 wallclock secs ( 0.18 usr 0.02 sys + 20.28 cusr
0.32 csys = 20.80 CPU)
After:
Files=1, Tests=840, 17 wallclock secs ( 0.06 usr 0.01 sys + 21.56 cusr
0.48 csys = 22.11 CPU)
Signed-off-by: David Bourgault <david.bourgault@inlibro.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
use Modern::Perl;
+use threads; # used for parallel
+use Parallel::ForkManager;
+use Sys::CPU;
+
=head1 NAME
valid-templates.t
}
close $dh;
+my $ncpu;
+if ( $ENV{KOHA_PROVE_CPUS} ) {
+ $ncpu = $ENV{KOHA_PROVE_CPUS} ; # set number of cpus to use
+} else {
+ $ncpu = Sys::CPU::cpu_count();
+}
+
+my $pm = new Parallel::ForkManager($ncpu);
+
# Tests
foreach my $theme ( @themes ) {
+ $pm->start and next; # do the fork
print "Testing $theme->{'type'} $theme->{'theme'} templates\n";
if ( $theme->{'theme'} eq 'bootstrap' ) {
run_template_test(
$theme->{'includes'},
);
}
+ $pm->finish;
}
+$pm->wait_all_children;
+
done_testing();
sub run_template_test {