-
-
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
Test: Add syntax tests and add missing use warnings #712
Conversation
t/~syntax.t
Outdated
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.
Is the name supposed to start with ~?
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.
Just convention to let it be the first test to run, ~ is sorted before most other characters. We can use numbers or perhaps a testrules.yml
file too. https://perldoc.perl.org/TAP::Harness#new (look for testrules.yml)
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.
Apparently it's ran last now :-D Maybe it's the last one. Oh well. We can rename it and just drop the ~. It's not that many tests that you want to fail fast.
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.
That would be cleaner, yes.
Or at least please add a comment.
Btw, from "Add syntax tests" it was obvious enough that it's about tests :D |
t/syntax.t
Outdated
local $Test::Strict::TEST_WARNINGS = 1; | ||
|
||
my @dirs = ('t', 'bin', "$Bin/../share/shutter/resources/modules/"); | ||
my @files = Test::Strict::_all_perl_files(@dirs); |
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 use Test::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:
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Strict;
use FindBin qw/$Bin/;
# 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/");
all_perl_files_ok(@dirs);
done_testing;
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
A new dependency is introduced, but only while testing