Skip to content

Commit

Permalink
Simplify syntax test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomen committed Oct 30, 2024
1 parent f60b155 commit 2ae7613
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
1 change: 0 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ requires "File::Copy::Recursive";
requires "Moo", ">= 2.0";

test_requires "Test::MockModule";
test_requires "Test2::AsyncSubtest";
test_requires "Test::Strict";
38 changes: 4 additions & 34 deletions t/syntax.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,12 @@ use FindBin qw/$Bin/;
use POSIX qw( waitpid WNOHANG );
use Time::HiRes qw( sleep );

# Check syntax, use strict and use warnings on all perl files

local $Test::Strict::TEST_WARNINGS = 1;

my @dirs = ('t', 'bin', "$Bin/../share/shutter/resources/modules/");
my @files = Test::Strict::_all_perl_files(@dirs);

run_parallel_tests(
4,
[
map {
my $file = $_;
sub { all_perl_files_ok($file); };
} @files
],
"Syntax and strict checks for @dirs"
);

sub run_parallel_tests {
my ($MAX_JOBS, $tests, $name) = @_;

my $ast = Test2::AsyncSubtest->new(name => $name);

my @tests = @{$tests || []};

my %children;

while (@tests) {
if (keys %children < $MAX_JOBS) {
my $pid = $ast->run_fork(shift @tests);
$children{$pid}++;
}
waitpid($_, WNOHANG) && delete $children{$_} for keys %children;

last if !@tests;
sleep 0.01;
}
$ast->finish;
}

all_perl_files_ok(@dirs);

done_testing;

0 comments on commit 2ae7613

Please sign in to comment.