]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Macos playtest envvars fix (#3035)
authorYonatan Komornik <11005061+yoniko@users.noreply.github.com>
Fri, 4 Feb 2022 02:42:20 +0000 (18:42 -0800)
committerGitHub <noreply@github.com>
Fri, 4 Feb 2022 02:42:20 +0000 (18:42 -0800)
* playtests.sh: fix for a bug in macos' /bin/sh that persists temporary env vars when introduced before function calls
* cli-tests/run.py: Do not use existing ZSTD* envvars

tests/cli-tests/run.py
tests/playTests.sh

index 6791918a5bd92b9727b1ed4c283c30ab4989f9d9..39b53a09bc5d48dfd2672470ed4384521ef7832d 100755 (executable)
@@ -278,10 +278,12 @@ class TestCase:
         Returns the environment to be used for the
         test subprocess.
         """
-        env = copy.copy(os.environ)
+        # We want to omit ZSTD cli flags so tests will be consistent across environments
+        env = {k: v for k, v in os.environ.items() if not k.startswith("ZSTD")}
         for k, v in self._opts.env.items():
             self._vlog(f"${k}='{v}'")
             env[k] = v
+        return env
 
     def _launch_test(self) -> None:
         """Launch the test subprocess, but do not join it."""
index f97e96e374a47f8dae0e32aef3f7a6137c61be7d..9b01d4d5eaf5c78ce559083b780649643fb9d89c 100755 (executable)
@@ -2,6 +2,10 @@
 
 set -e
 
+unset ZSTD_CLEVEL
+unset ZSTD_NBTHREADS
+
+
 die() {
     println "$@" 1>&2
     exit 1
@@ -210,6 +214,7 @@ zstd -c --fast=0 tmp > $INTOVOID && die "--fast must not accept value 0"
 println "test : too large numeric argument"
 zstd --fast=9999999999 -f tmp  && die "should have refused numeric value"
 println "test : set compression level with environment variable ZSTD_CLEVEL"
+
 ZSTD_CLEVEL=12  zstd -f tmp # positive compression level
 ZSTD_CLEVEL=-12 zstd -f tmp # negative compression level
 ZSTD_CLEVEL=+12 zstd -f tmp # valid: verbose '+' sign
@@ -221,6 +226,11 @@ ZSTD_CLEVEL=3a7 zstd -f tmp # malformed env var, warn and revert to default sett
 ZSTD_CLEVEL=50000000000 zstd -f tmp # numeric value too large, warn and revert to default setting
 println "test : override ZSTD_CLEVEL with command line option"
 ZSTD_CLEVEL=12  zstd --fast=3 -f tmp # overridden by command line option
+
+# temporary envvar chnages in the above tests would actually persist in macos /bin/sh
+unset ZSTD_CLEVEL
+
+
 println "test : compress to stdout"
 zstd tmp -c > tmpCompressed
 zstd tmp --stdout > tmpCompressed       # long command format
@@ -1465,6 +1475,8 @@ then
     ZSTD_NBTHREADS=50000000000 zstd -f mt_tmp # numeric value too large, warn and revert to default setting=
     ZSTD_NBTHREADS=2  zstd -f mt_tmp # correct usage
     ZSTD_NBTHREADS=1  zstd -f mt_tmp # correct usage: single thread
+    # temporary envvar chnages in the above tests would actually persist in macos /bin/sh
+    unset ZSTD_NBTHREADS
     rm -f mt_tmp*
 
     println "\n===>  ovLog tests "