]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
meson: valgrind wrapper should return correct errors
authorEli Schwartz <eschwartz@archlinux.org>
Mon, 31 Jan 2022 02:45:19 +0000 (21:45 -0500)
committerEli Schwartz <eschwartz@archlinux.org>
Mon, 31 Jan 2022 02:50:42 +0000 (21:50 -0500)
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

index 218f7458bbf18a045646f5fb90dd884dd93b1834..05d84878b9dcd53ee503fcf24ba7bb58f4a812c0 100644 (file)
@@ -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'])