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
This commit is contained in:
@@ -278,10 +278,12 @@ class TestCase:
|
|||||||
Returns the environment to be used for the
|
Returns the environment to be used for the
|
||||||
test subprocess.
|
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():
|
for k, v in self._opts.env.items():
|
||||||
self._vlog(f"${k}='{v}'")
|
self._vlog(f"${k}='{v}'")
|
||||||
env[k] = v
|
env[k] = v
|
||||||
|
return env
|
||||||
|
|
||||||
def _launch_test(self) -> None:
|
def _launch_test(self) -> None:
|
||||||
"""Launch the test subprocess, but do not join it."""
|
"""Launch the test subprocess, but do not join it."""
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
unset ZSTD_CLEVEL
|
||||||
|
unset ZSTD_NBTHREADS
|
||||||
|
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
println "$@" 1>&2
|
println "$@" 1>&2
|
||||||
exit 1
|
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"
|
println "test : too large numeric argument"
|
||||||
zstd --fast=9999999999 -f tmp && die "should have refused numeric value"
|
zstd --fast=9999999999 -f tmp && die "should have refused numeric value"
|
||||||
println "test : set compression level with environment variable ZSTD_CLEVEL"
|
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 # positive compression level
|
||||||
ZSTD_CLEVEL=-12 zstd -f tmp # negative compression level
|
ZSTD_CLEVEL=-12 zstd -f tmp # negative compression level
|
||||||
ZSTD_CLEVEL=+12 zstd -f tmp # valid: verbose '+' sign
|
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
|
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"
|
println "test : override ZSTD_CLEVEL with command line option"
|
||||||
ZSTD_CLEVEL=12 zstd --fast=3 -f tmp # overridden by 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"
|
println "test : compress to stdout"
|
||||||
zstd tmp -c > tmpCompressed
|
zstd tmp -c > tmpCompressed
|
||||||
zstd tmp --stdout > tmpCompressed # long command format
|
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=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=2 zstd -f mt_tmp # correct usage
|
||||||
ZSTD_NBTHREADS=1 zstd -f mt_tmp # correct usage: single thread
|
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*
|
rm -f mt_tmp*
|
||||||
|
|
||||||
println "\n===> ovLog tests "
|
println "\n===> ovLog tests "
|
||||||
|
|||||||
Reference in New Issue
Block a user