diff mbox series

[v2,7/7] tests/functional: stop output from zstd command when uncompressing

Message ID 20250228102738.3064045-8-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series tests/functional: a few misc cleanups and fixes | expand

Commit Message

Daniel P. Berrangé Feb. 28, 2025, 10:27 a.m. UTC
The zstd command will print incremental decompression progress to stderr
when running. Fortunately it is not on stdout as that would confuse the
TAP parsing, but we should still not have this printed. By switching
from 'check_call' to 'run' with the check=True and capture_output=True
we'll get the desired silence on success, and on failure the raised
exception will automatically include stdout/stderr data for diagnosis
purposes.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/functional/qemu_test/uncompress.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Thomas Huth March 5, 2025, 9:05 a.m. UTC | #1
On 28/02/2025 11.27, Daniel P. Berrangé wrote:
> The zstd command will print incremental decompression progress to stderr
> when running. Fortunately it is not on stdout as that would confuse the
> TAP parsing, but we should still not have this printed. By switching
> from 'check_call' to 'run' with the check=True and capture_output=True
> we'll get the desired silence on success, and on failure the raised
> exception will automatically include stdout/stderr data for diagnosis
> purposes.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/functional/qemu_test/uncompress.py | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/functional/qemu_test/uncompress.py b/tests/functional/qemu_test/uncompress.py
> index 76dcf22385..ce79da1b68 100644
> --- a/tests/functional/qemu_test/uncompress.py
> +++ b/tests/functional/qemu_test/uncompress.py
> @@ -13,7 +13,7 @@
>   import stat
>   import shutil
>   from urllib.parse import urlparse
> -from subprocess import check_call, CalledProcessError
> +from subprocess import run, CalledProcessError, DEVNULL
>   
>   from .asset import Asset
>   
> @@ -46,8 +46,8 @@ def zstd_uncompress(zstd_path, output_path):
>           return
>   
>       try:
> -        check_call(['zstd', "-f", "-d", zstd_path,
> -                    "-o", output_path])
> +        run(['zstd', "-f", "-d", zstd_path,
> +             "-o", output_path], capture_output=True, check=True)
>       except CalledProcessError as e:
>           os.remove(output_path)
>           raise Exception(

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/tests/functional/qemu_test/uncompress.py b/tests/functional/qemu_test/uncompress.py
index 76dcf22385..ce79da1b68 100644
--- a/tests/functional/qemu_test/uncompress.py
+++ b/tests/functional/qemu_test/uncompress.py
@@ -13,7 +13,7 @@ 
 import stat
 import shutil
 from urllib.parse import urlparse
-from subprocess import check_call, CalledProcessError
+from subprocess import run, CalledProcessError, DEVNULL
 
 from .asset import Asset
 
@@ -46,8 +46,8 @@  def zstd_uncompress(zstd_path, output_path):
         return
 
     try:
-        check_call(['zstd', "-f", "-d", zstd_path,
-                    "-o", output_path])
+        run(['zstd', "-f", "-d", zstd_path,
+             "-o", output_path], capture_output=True, check=True)
     except CalledProcessError as e:
         os.remove(output_path)
         raise Exception(