From 3ee997c2e21f1e1488e518e58d3d5c9a369433d1 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 10 Feb 2017 17:19:44 +0100 Subject: [PATCH] Tests: t/structure/common_errors.t parallelisiert --- t/structure/common_errors.t | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) mode change 100644 => 100755 t/structure/common_errors.t diff --git a/t/structure/common_errors.t b/t/structure/common_errors.t old mode 100644 new mode 100755 index c23c6b480..ab0ff3b27 --- a/t/structure/common_errors.t +++ b/t/structure/common_errors.t @@ -1,8 +1,11 @@ #!/usr/bin/perl use strict; +use threads; use lib 't'; use Support::Files; +use Sys::CPU; +use Thread::Pool::Simple; my ($testcount); @@ -38,9 +41,10 @@ my @common_errors = ([ '^\s*my\s+%[a-z0-9_]+\s*=\s*shift' ], [ '\$slef' ], ); -foreach my $file (@testitems) { +sub test_file { + my ($file) = @_; $file =~ s/\s.*$//; # nuke everything after the first space (#comment) - next if (!$file); # skip null entries + return if (!$file); # skip null entries if (open (FILE, $file)) { # open the file for reading $_->[1] = [] foreach @common_errors; @@ -67,5 +71,15 @@ foreach my $file (@testitems) { } } -exit 0; +my $pool = Thread::Pool::Simple->new( + min => 2, + max => Sys::CPU::cpu_count() + 1, + do => [ \&test_file ], + passid => 0, +); + +$pool->add($_) for @testitems; +$pool->join; + +exit 0; -- 2.20.1