Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions lib/Zonemaster/CLI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ has 'test' => (
isa => 'ArrayRef',
required => 0,
documentation => __(
'Specify test to run case-insensitively. Should be either the name of a module, or the name of a module and the name of a method in that module separated by a "/" character (Example: "Basic/basic01"). This switch can be repeated.'
'Specify test case to be run. Should be the case-insensitive name of a test module (e.g. "Delegation") and/or a test case (e.g. "Delegation/delegation01" or "delegation01"). This switch can be repeated.'
)
);

Expand Down Expand Up @@ -621,13 +621,24 @@ sub run {
# Actually run tests!
eval {
if ( $self->test and @{ $self->test } > 0 ) {
my $zone = Zonemaster::Engine->zone( $domain );
foreach my $t ( @{ $self->test } ) {
my ( $module, $method ) = split( '/', lc($t), 2 );
if ( $method ) {
Zonemaster::Engine->test_method( $module, $method, Zonemaster::Engine->zone( $domain ) );
# The case does not matter
$t = lc( $t );
# Fully qualified module and test case (e.g. Example/example12)
if (my ($module, $method) = $t =~ m#^ ( [a-z]+ ) / ( [a-z]+[0-9]{2} ) $#ix) {
Zonemaster::Engine->test_method( $module, $method, $zone );
}
# Just a test case (e.g. example12). Note the different capturing order.
elsif (($method, $module) = $t =~ m#^ ( ( [a-z]+ ) [0-9]{2} ) $#ix) {
Zonemaster::Engine->test_method( $module, $method, $zone );
}
# Just a module name (e.g. Example) or something invalid.
# TODO: in case of invalid input, print a proper error message
# suggesting to use --list-tests for valid choices.
else {
Zonemaster::Engine->test_module( $module, $domain );
$t =~ s{/$}{};
Zonemaster::Engine->test_module( $t, $domain );
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions script/zonemaster-cli
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,14 @@ Default: on

Print all test cases listed in the test modules, then exit.

=item --test=MODULE, --test=MODULE/TESTCASE
=item --test=MODULE, --test=MODULE/TESTCASE, --test=TESTCASE

Limit the testing suite to run only the specified tests.
This can be the name of a testing module, in which case all test cases from
that module will be run, or the name of a module followed by a slash and the
name of a test case (test case identifier) in that module.
name of a test case (test case identifier) in that module, or the name of the
test case.
Can be specified multiple times.
This option is case-insensitive.

=item --stop_level=LEVEL, --stop-level=LEVEL
Expand Down