-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test: Add syntax tests and add missing use warnings #712
Merged
DarthGandalf
merged 6 commits into
shutter-project:master
from
nicomen:add-syntax-tests
Oct 31, 2024
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9cdcf93
Test: Add syntax tests and add missing use warnings
nicomen 63d9e61
Test: Add missing test dependency
nicomen 49096bf
Test: Drop fancy tilde in test file name. Order is not so important
nicomen f60b155
Merge branch 'shutter-project:master' into add-syntax-tests
nicomen 2ae7613
Simplify syntax test
nicomen e840565
Remove unused modules
nicomen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use Test::Strict; | ||
use Test2::AsyncSubtest; | ||
|
||
use FindBin qw/$Bin/; | ||
use POSIX qw( waitpid WNOHANG ); | ||
use Time::HiRes qw( sleep ); | ||
|
||
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; | ||
} | ||
|
||
done_testing; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a private function of Test::Strict? It's not documented at https://metacpan.org/pod/Test::Strict
Why
all_perl_files_ok
was not enough?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To run them in parallell. First it finds all files to test with
_all_perl_files
, then in the next part below it runs them in parallell, in this case 4 at a time. I could find "all perl-like" files myself, but thought it was best to useTest::Strict
own way to find them.This is just a standard syntax check I add in all projects.
When a project is big it gets slow to run syntax checks on all files sequentially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be just this:
Locally that takes 10 seconds vs 4 seconds in parallell.
If you prefer I can use the "simple" approach instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 seconds is good enough. Additional 6 seconds don't deserve the added complexity