aboutsummaryrefslogtreecommitdiff
path: root/tests/runtests.pl
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2020-02-23 08:20:32 +0000
committerSteve Holme <steve_holme@hotmail.com>2020-02-27 00:51:49 +0000
commit0922f762407cc20c90f8f5cfa01c5eafbdfecde0 (patch)
tree9a3a672688a9197c66b66338e6c2a994e37b18d6 /tests/runtests.pl
parentd9e40f57de17bff9e96f76f502e611dd1b70feac (diff)
tests: Automatically deduce the tool name from the test case for unit tests
It is still possible to override the executable to run during the test, using the <tool> tag, but this patch removes the requirement that the tag must be present for unit tests. It also removes the possibility of human error when existing test cases are used as the basis for new tests, as recently witnessed in 81c37124. Reviewed-by: Daniel Stenberg Closes #4976
Diffstat (limited to 'tests/runtests.pl')
-rwxr-xr-xtests/runtests.pl21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index bef95574d..61953ea64 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -296,7 +296,8 @@ my %timevrfyend; # timestamp for each test result verification end
my $testnumcheck; # test number, set in singletest sub.
my %oldenv;
-my %feature; # array of enabled features
+my %feature; # array of enabled features
+my %keywords; # array of keywords from the test spec
#######################################################################
# variables that command line options may set
@@ -3306,21 +3307,26 @@ sub singletest {
}
if(!$why) {
- my @keywords = getpart("info", "keywords");
+ my @info_keywords = getpart("info", "keywords");
my $match;
my $k;
- if(!$keywords[0]) {
+ # Clear the list of keywords from the last test
+ %keywords = ();
+
+ if(!$info_keywords[0]) {
$why = "missing the <keywords> section!";
}
- for $k (@keywords) {
+ for $k (@info_keywords) {
chomp $k;
if ($disabled_keywords{lc($k)}) {
$why = "disabled by keyword";
} elsif ($enabled_keywords{lc($k)}) {
$match = 1;
}
+
+ $keywords{$k} = 1;
}
if(!$why && !$match && %enabled_keywords) {
@@ -3616,7 +3622,7 @@ sub singletest {
$tool=$CMDLINE;
$disablevalgrind=1;
}
- elsif(!$tool) {
+ elsif(!$tool && !$keywords{"unittest"}) {
# run curl, add suitable command line options
my $inc="";
if((!$cmdhash{'option'}) || ($cmdhash{'option'} !~ /no-include/)) {
@@ -3636,6 +3642,11 @@ sub singletest {
$cmdargs = " $cmd"; # $cmd is the command line for the test file
$CURLOUT = $STDOUT; # sends received data to stdout
+ # Default the tool to a unit test with the same name as the test spec
+ if($keywords{"unittest"} && !$tool) {
+ $tool="unit$testnum";
+ }
+
if($tool =~ /^lib/) {
$CMDLINE="$LIBDIR/$tool";
}