From ef78b9af30422f8affe1ab35cd59b7170cde707a Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Jan 2022 21:45:19 -0500 Subject: [PATCH] meson: valgrind wrapper should return correct errors While trying to raise an exception on failures, it instead raised an exception for misusing the exception. CalledProcessError is only supposed to be used when given a return code and a command, and it prints: Command '{cmd}' returned non-zero exit status {ret} Passing an error message string instead, just errored out with: TypeError: __init__() missing 1 required positional argument Instead use the subprocess module's base error which does accept string messages. Everything that used to error out, still errors out, but now they do so with a slightly prettier console message. --- build/meson/tests/valgrindTest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/meson/tests/valgrindTest.py b/build/meson/tests/valgrindTest.py index 218f7458..05d84878 100644 --- a/build/meson/tests/valgrindTest.py +++ b/build/meson/tests/valgrindTest.py @@ -21,7 +21,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): if subprocess.call([*VALGRIND_ARGS, zstd], stdout=subprocess.DEVNULL) == 0: - raise subprocess.CalledProcessError('zstd without argument should have failed') + raise subprocess.SubprocessError('zstd without argument should have failed') with subprocess.Popen([datagen, '-g80'], stdout=subprocess.PIPE) as p1, \ subprocess.Popen([*VALGRIND_ARGS, zstd, '-', '-c'], @@ -30,7 +30,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() with subprocess.Popen([datagen, '-g16KB'], stdout=subprocess.PIPE) as p1, \ subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], @@ -39,7 +39,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() with tempfile.NamedTemporaryFile() as tmp_fd: with subprocess.Popen([datagen, '-g2930KB'], stdout=subprocess.PIPE) as p1, \ @@ -48,7 +48,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() subprocess.check_call([*VALGRIND_ARGS, zstd, '-vdf', tmp_fd.name, '-c'], stdout=subprocess.DEVNULL) @@ -60,7 +60,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() subprocess.check_call([*VALGRIND_ARGS, fuzzer, '-T1mn', '-t1']) subprocess.check_call([*VALGRIND_ARGS, fullbench, '-i1'])