Use exit code 255 to signal skipped integration test.

This commit is contained in:
jcamiel 2023-10-12 22:52:53 +02:00
parent 9d5b611b9e
commit 46e3bf2cfb
No known key found for this signature in database
GPG Key ID: 07FF11CFD55356CC
7 changed files with 26 additions and 17 deletions

View File

@ -35,22 +35,32 @@ def test(script_file: str):
print(cmd)
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
test_exit_code(os.path.splitext(script_file)[0] + ".exit", result)
test_stdout(os.path.splitext(script_file)[0] + ".out", result)
test_stdout_pattern(os.path.splitext(script_file)[0] + ".out.pattern", result)
test_stderr(os.path.splitext(script_file)[0] + ".err", result)
test_stderr_pattern(os.path.splitext(script_file)[0] + ".err.pattern", result)
basename = os.path.splitext(script_file)[0]
_continue = test_exit_code(f"{basename}.exit", result)
if not _continue:
print(f"{cmd} - skipped")
return
test_stdout(f"{basename}.out", result)
test_stdout_pattern(f"{basename}.out.pattern", result)
test_stderr(f"{basename}.err", result)
test_stderr_pattern(f"{basename}.err.pattern", result)
def test_exit_code(f, result) -> int:
"""test exit code"""
def test_exit_code(f: str, result: subprocess.CompletedProcess) -> bool:
"""Test actual exit code `result` against an expected exit code in file `f`"""
if os.path.exists(f):
expected = int(open(f, encoding="utf-8").read().strip())
else:
expected = 0
if result.returncode != expected:
actual = result.returncode
# Exit code 255 is the signal to skip test.
if actual == 255:
return False
if actual != expected:
print(">>> error in return code")
print(f"expected: {expected} actual:{result.returncode}")
print(f"expected: {expected} actual:{actual}")
stderr = decode_string(result.stderr).strip()
if stderr != "":
print(stderr)
@ -60,7 +70,7 @@ def test_exit_code(f, result) -> int:
sys.exit(1)
return expected
return True
def test_stdout(f, result):

View File

@ -7,8 +7,7 @@ set +eo pipefail
# simply ignore test if option is available on the system
# FIXME: remove this test once all integration test targets have aws-sigv4 support in libcurl
if curl --aws-sigv4 2>&1 | grep -qv 'option --aws-sigv4: is unknown'; then
cat tests_failed/aws_sigv4_option.err >&2
exit 3
exit 255
fi
set -Eeuo pipefail

View File

@ -6,7 +6,7 @@ set +eo pipefail
# simply ignore test
# FIXME: remove this workaround once all integration test targets have aws-sigv4 support in libcurl
if curl --aws-sigv4 2>&1 | grep -q 'option --aws-sigv4: is unknown'; then
exit 0
exit 255
fi
set -Eeuo pipefail

View File

@ -4,7 +4,7 @@ $ErrorActionPreference = 'Stop'
$ErrorActionPreference = 'Continue'
curl --version | grep Features | grep -q HTTP2
if ($LASTEXITCODE -eq 1) {
exit 0
exit 255
}
$ErrorActionPreference = 'Stop'

View File

@ -4,7 +4,7 @@ set -Eeuo pipefail
set +eo pipefail
curl --version | grep Features | grep -q HTTP2
if [ $? -eq 1 ]; then
exit 0
exit 255
fi
set -Eeuo pipefail

View File

@ -4,7 +4,7 @@ $ErrorActionPreference = 'Stop'
$ErrorActionPreference = 'Continue'
curl --version | grep Features | grep -q HTTP3
if ($LASTEXITCODE -eq 1) {
exit 0
exit 255
}
$ErrorActionPreference = 'Stop'

View File

@ -4,7 +4,7 @@ set -Eeuo pipefail
set +eo pipefail
curl --version | grep Features | grep -q HTTP3
if [ $? -eq 1 ]; then
exit 0
exit 255
fi
set -Eeuo pipefail