Browse Source

tests: support setting/using blank content env variables

- test450: remove --config from the keywords
- test2080: change return code
- test428: add --config as a keyword
- test428: disable on Windows due to CI problems
Daniel Stenberg 2 months ago
parent
commit
7cf8414fab
5 changed files with 26 additions and 8 deletions
  1. 6 1
      tests/FILEFORMAT.md
  2. BIN
      tests/data/test2080
  3. 9 0
      tests/data/test428
  4. 0 1
      tests/data/test450
  5. 11 6
      tests/runner.pm

+ 6 - 1
tests/FILEFORMAT.md

@@ -522,9 +522,14 @@ Brief test case description, shown when the test runs.
 ### `<setenv>`
     variable1=contents1
     variable2=contents2
+    variable3
 
 Set the given environment variables to the specified value before the actual
-command is run. They are cleared again after the command has been run.
+command is run. They are restored back to their former values again after the
+command has been run.
+
+If the variable name has no assignment, no `=`, then that variable is just
+deleted.
 
 ### `<command [option="no-output/no-include/force-output/binary-trace"] [timeout="secs"][delay="secs"][type="perl/shell"]>`
 Command line to run.

BIN
tests/data/test2080


+ 9 - 0
tests/data/test428

@@ -3,6 +3,7 @@
 <keywords>
 HTTP
 variables
+--config
 </keywords>
 </info>
 
@@ -28,6 +29,14 @@ Funny-head: yesyes
 #
 # Client-side
 <client>
+
+# For unknown reasons, a number of CI jobs on Appveyor keep returning NULL to
+# getenv() for the blank environment variable which makes the test fail.
+# Unfortunately, this makes me disable the test completely on Windows.
+
+<features>
+!win32
+</features>
 <server>
 http
 </server>

+ 0 - 1
tests/data/test450

@@ -2,7 +2,6 @@
 <info>
 <keywords>
 HTTP
---config
 variables
 </keywords>
 </info>

+ 11 - 6
tests/runner.pm

@@ -648,15 +648,15 @@ sub singletest_setenv {
     my @setenv = getpart("client", "setenv");
     foreach my $s (@setenv) {
         chomp $s;
-        if($s =~ /([^=]*)=(.*)/) {
+        if($s =~ /([^=]*)(.*)/) {
             my ($var, $content) = ($1, $2);
             # remember current setting, to restore it once test runs
             $oldenv{$var} = ($ENV{$var})?"$ENV{$var}":'notset';
-            # set new value
-            if(!$content) {
-                delete $ENV{$var} if($ENV{$var});
-            }
-            else {
+
+            if($content =~ /^=(.*)/) {
+                # assign it
+                $content = $1;
+
                 if($var =~ /^LD_PRELOAD/) {
                     if(exe_ext('TOOL') && (exe_ext('TOOL') eq '.exe')) {
                         logmsg "Skipping LD_PRELOAD due to lack of OS support\n" if($verbose);
@@ -670,6 +670,11 @@ sub singletest_setenv {
                 $ENV{$var} = "$content";
                 logmsg "setenv $var = $content\n" if($verbose);
             }
+            else {
+                # remove it
+                delete $ENV{$var} if($ENV{$var});
+            }
+
         }
     }
     if($proxy_address) {