t: Add check script to ensure test modules compile with strict#24921
Open
perlpunk wants to merge 1 commit intoos-autoinst:masterfrom
Open
t: Add check script to ensure test modules compile with strict#24921perlpunk wants to merge 1 commit intoos-autoinst:masterfrom
perlpunk wants to merge 1 commit intoos-autoinst:masterfrom
Conversation
This script will load all test modules under tests/ with the ENABLE_MODERN_PERL_FEATURES
setting, which automatically adds
use Mojo::Base -strict, -signatures;
at the top.
You can use it to check all modules by doing
prove tools/check_strict
or check specific files with
perl tools/check_strict tests/category/one.pm tests/category/two.pm
Issue: https://progress.opensuse.org/issues/194002
okurz
approved these changes
Mar 11, 2026
foursixnine
approved these changes
Mar 11, 2026
Member
This is also really useful as part of pre-commit hooks together with a target in the Makefile |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This script will load all test modules under tests/ with the
ENABLE_MODERN_PERL_FEATURESsetting, which automatically addsat the top.
You can use it to check all modules by doing
or check specific files with
This will fail right now, as there are many modules which use undeclared variables.
Please see #24709 for that and try to fix those issues in the modules you maintain. If you need any help / explanation for the error and how to fix it, don't hesitate to ask me for help.
Once we have fixed all errors, we can activate this as a CI check.
You will see a lot of warnings when running this. Those are currently not fatal, but I will work on that as a next step.
An alternative would be to not use the
ENABLE_MODERN_PERL_FEATURES, but write a script that adds this line automatically to the source code in github - permanantly. The advantage is that you would be able to run a normal compile time check viaperl -c tests/category/module.pmand get an error for undeclared variables or other strict errors.With the above script, you always have to use that, because it only adds the strictures on the fly.
Let me know what you would prefer for osado.