From: Daniel Stenberg Date: Mon, 5 Feb 2024 16:04:28 +0000 (+0100) Subject: tests: support setting/using blank content env variables X-Git-Tag: curl-8_7_0~205 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7cf8414fabc3063cc3d2121eacec4a6daa4164a8;p=thirdparty%2Fcurl.git 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 --- diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 5a8e783232..b594fc1130 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -522,9 +522,14 @@ Brief test case description, shown when the test runs. ### `` 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 line to run. diff --git a/tests/data/test2080 b/tests/data/test2080 index 7f08385b6f..c3792f43de 100644 Binary files a/tests/data/test2080 and b/tests/data/test2080 differ diff --git a/tests/data/test428 b/tests/data/test428 index c06f2f9dff..fbb714f5c8 100644 --- a/tests/data/test428 +++ b/tests/data/test428 @@ -3,6 +3,7 @@ HTTP variables +--config @@ -28,6 +29,14 @@ Funny-head: yesyes # # Client-side + +# 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. + + +!win32 + http diff --git a/tests/data/test450 b/tests/data/test450 index a6fa641036..5dcfb85ce6 100644 --- a/tests/data/test450 +++ b/tests/data/test450 @@ -2,7 +2,6 @@ HTTP ---config variables diff --git a/tests/runner.pm b/tests/runner.pm index c0fb40cb3d..645905e5f6 100644 --- a/tests/runner.pm +++ b/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) {