From: Jeremy Harris Date: Tue, 5 Sep 2023 13:01:10 +0000 (+0100) Subject: Testsuite: support "anything but" returncode script lines X-Git-Tag: exim-4.97-RC0~9 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/5dec5c7c0e98805bf8f345fe16b36ba676f24c4b Testsuite: support "anything but" returncode script lines --- diff --git a/test/README b/test/README index d013f7823..c0bfa04f1 100644 --- a/test/README +++ b/test/README @@ -681,7 +681,12 @@ script. For example: # -bS Use of HELO/RSET A line consisting just of digits is interpreted as the expected return code -for the command that follows. The default expectation when no such line exists +for the command that follows. + +A line consisting of a tilde (~) followed by digits indicates a non-expected +return code for the command that follows. + +The default expectation when neither such line exists is a zero return code. For example, here is a complete test script, containing just one command: diff --git a/test/runtest b/test/runtest index 204e09e76..629b45dbf 100755 --- a/test/runtest +++ b/test/runtest @@ -2305,6 +2305,7 @@ system($cmd); # Arguments: the current test number # reference to the subtest number, holding previous value # reference to the expected return code value +# reference to flag for not-expected return value # reference to where to put the command name (for messages) # auxiliary information returned from a previous run # @@ -2320,17 +2321,18 @@ system($cmd); sub run_command{ my($testno) = $_[0]; my($subtestref) = $_[1]; -my($commandnameref) = $_[3]; -my($aux_info) = $_[4]; +my($commandnameref) = $_[4]; +my($aux_info) = $_[5]; my($yield) = 1; our %ENV = map { $_ => $ENV{$_} } grep { /^(?:USER|SHELL|PATH|TERM|EXIM_TEST_.*)$/ } keys %ENV; -if (/^(\d+)\s*(?:([A-Z]+)=(\S+))?$/) # Handle unusual return code +if (/^(~)?(\d+)\s*(?:([A-Z]+)=(\S+))?$/) # Handle unusual return code { - my($r) = $_[2]; - $$r = $1 << 8; - $ENV{$2} = $3 if (defined $2); + my($r, $rn) = ($_[2], $_[3]); + $$r = $2 << 8; + $$rn = 1 if (defined $1); + $ENV{$3} = $4 if (defined $3); $_ =