Skip to content

Add dry-run mode to test.pl #1356

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

Merged
Merged
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
18 changes: 12 additions & 6 deletions regression/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ ($)
return @data;
}

sub test($$$$$) {
my ($name, $test, $t_level, $cmd, $ign) = @_;
sub test($$$$$$) {
my ($name, $test, $t_level, $cmd, $ign, $dry_run) = @_;
my ($level, $input, $options, $grep_options, @results) = load("$test");

# If the 4th line is activate-multi-line-match we enable multi-line checks
Expand Down Expand Up @@ -106,6 +106,11 @@ ($$$$$)

my $failed = 2;
if($level & $t_level) {

if ($dry_run) {
return 0;
}

$failed = run($name, $input, $cmd, $options, $output);

if(!$failed) {
Expand Down Expand Up @@ -211,6 +216,7 @@ ($$$$)
-c CMD run tests on CMD - required option
-i <regex> options in test.desc matching the specified perl regex are ignored
-j <num> run <num> tests in parallel (requires Thread::Pool::Simple)
-n dry-run: print the tests that would be run, but don't actually run them
-h show this help and exit
-C core: run all essential tests (default if none of C/T/F/K are given)
-T thorough: run expensive tests
Expand Down Expand Up @@ -249,9 +255,9 @@ ($$$$)
use Getopt::Std;
$main::VERSION = 0.1;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
our ($opt_c, $opt_i, $opt_j, $opt_h, $opt_C, $opt_T, $opt_F, $opt_K); # the variables for getopt
our ($opt_c, $opt_i, $opt_j, $opt_n, $opt_h, $opt_C, $opt_T, $opt_F, $opt_K); # the variables for getopt
$opt_j = 0;
getopts('c:i:j:hCTFK') or &main::HELP_MESSAGE(\*STDOUT, "", $main::VERSION, "");
getopts('c:i:j:nhCTFK') or &main::HELP_MESSAGE(\*STDOUT, "", $main::VERSION, "");
$opt_c or &main::HELP_MESSAGE(\*STDOUT, "", $main::VERSION, "");
(!$opt_j || $has_thread_pool) or &main::HELP_MESSAGE(\*STDOUT, "", $main::VERSION, "");
$opt_h and &main::HELP_MESSAGE(\*STDOUT, "", $main::VERSION, "");
Expand All @@ -260,7 +266,7 @@ ($$$$)
$t_level += 4 if($opt_F);
$t_level += 8 if($opt_K);
$t_level += 1 if($opt_C || 0 == $t_level);

my $dry_run = $opt_n;


open LOG,">tests.log";
Expand All @@ -287,7 +293,7 @@ ($)
my @files = glob "$test/*.desc";
for (0..$#files){
defined($pool) or print " Running $files[$_]";
$failed_skipped = test($test, $files[$_], $t_level, $opt_c, $opt_i);
$failed_skipped = test($test, $files[$_], $t_level, $opt_c, $opt_i, $dry_run);

lock($skips);
defined($pool) and print " Running $test $files[$_]";
Expand Down