X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fstructure%2Fno_lexicals_in_postif.t;h=b9f9c4cdfe42874a69eaab533b5d45d685b57996;hb=45ee0662e55cf328d365c1662694cc1b333c723d;hp=bb15c9cc952a9fe083f2567e78132b3507431f26;hpb=f4d859337868ec181836a6acbefc3c764993b80f;p=kivitendo-erp.git diff --git a/t/structure/no_lexicals_in_postif.t b/t/structure/no_lexicals_in_postif.t index bb15c9cc9..b9f9c4cdf 100644 --- a/t/structure/no_lexicals_in_postif.t +++ b/t/structure/no_lexicals_in_postif.t @@ -1,7 +1,10 @@ use strict; +use threads; use lib 't'; use Support::Files; +use Sys::CPU; use Test::More; +use Thread::Pool::Simple; if (eval { require PPI; 1 }) { plan tests => scalar(@Support::Files::testitems); @@ -23,11 +26,26 @@ my $fh; my @testitems = @Support::Files::testitems; -foreach my $file (@testitems) { - next unless -f $file; +sub test_file { + my ($file) = @_; my $clean = 1; - my $doc = PPI::Document->new($file) or do { - ok 0, "PPI error for file $file: " . PPI::Document::errstr(); + my $source; + { + # due to a bug in PPI it cannot determine the encoding of a source file by + # use utf8; normaly this would be no problem but some people instist on + # putting strange stuff into the source. as a workaround read in the source + # with :utf8 layer and pass it to PPI by reference + # there are still some latin chars, but it's not the purpose of this test + # to find them, so warnings about it will be ignored + local $^W = 0; # don't care about invalid chars in comments + local $/ = undef; + open my $fh, '<:utf8', $file or die $!; + $source = <$fh>; + } + + my $doc = PPI::Document->new(\$source) or do { + print $fh "?: PPI error for file $file: " . PPI::Document::errstr() . "\n"; + ok 0, $file; next; }; my $stmts = $doc->find('Statement::Variable'); @@ -49,3 +67,14 @@ foreach my $file (@testitems) { ok $clean, $file; } + +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;