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
This commit is contained in:
Daniel Stenberg 2024-02-05 17:04:28 +01:00
parent 0f0edc283c
commit 7cf8414fab
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 26 additions and 8 deletions

View File

@ -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.

Binary file not shown.

View File

@ -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>

View File

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

View File

@ -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) {