-
Notifications
You must be signed in to change notification settings - Fork 21
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
Extend --test option to allow passing only a testcase #333
Conversation
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 change that I have wanted for a long time!
lib/Zonemaster/CLI.pm
Outdated
my ( $module, $method ) = split( '/', lc($t), 2 ); | ||
if ( $module =~ /^([a-z]+)[0-9]+$/ ) { | ||
$method = $module; | ||
$module = $1; | ||
} |
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.
If $module matches a test case identifier then $method can be any garbage. I guess that is OK in this context.
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.
I think this is a good point and that it should be fixed. Caring about proper input validation is a good thing.
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.
Yes, and the error message has room for improvement. Currently, this happens:
$ zonemaster-cli --test bogus42 domain.example
Seconds Level Message
======= ======== =======
0.00 CRITICAL Request to run bogus42 in unknown module bogus. Known modules: Address:Connectivity:Consistency:DNSSEC:Delegation:Nameserver:Syntax:Zone.
It would be more useful if the error message suggests the use of --list-tests
for correct inputs. But that’s a problem best addressed in another PR.
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.
Good idea. Currently the message comes from the Engine which has no idea of the --list-tests
CLI option. I guess it would mean rethinking how this message/error is emitted.
But that’s a problem best addressed in another PR.
I'll open an issue with your suggestion.
This is a good change, but there are possible improvements.
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.
Good idea, but I think there is room for improvement.
Following commands are identical: zonemaster-cli --test delegation/delegation01 zonemaster-cli --test delegation01 Passing a trailing '/' assumes a module should be run. Credits to @marc-vanderwal for most of this code.
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.
I think this is a great improvement.
I'd approve it, but it’s best if someone else had a look at the code. |
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.
Tested and it works as advertised. This is probably not a breaking change since the old behavior is kept so V-Minor, right?
v2023.2 Release TestingI successfully tested this on Rocky Linux 8.9. |
Purpose
Make it possible to only pass the name of a testcase to the
--test
option.The following commands are now both ok and identical:
Context
Fixes #232
Changes
--test
optionHow to test this PR