From: Yonatan Komornik <11005061+yoniko@users.noreply.github.com> Date: Fri, 4 Feb 2022 02:42:20 +0000 (-0800) Subject: Macos playtest envvars fix (#3035) X-Git-Tag: v1.5.4^2~247 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bba97b4cb8705447123a9447854b78662c82ba0;p=thirdparty%2Fzstd.git Macos playtest envvars fix (#3035) * 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 --- diff --git a/tests/cli-tests/run.py b/tests/cli-tests/run.py index 6791918a5..39b53a09b 100755 --- a/tests/cli-tests/run.py +++ b/tests/cli-tests/run.py @@ -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.""" diff --git a/tests/playTests.sh b/tests/playTests.sh index f97e96e37..9b01d4d5e 100755 --- a/tests/playTests.sh +++ b/tests/playTests.sh @@ -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 "