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."""
set -e
+unset ZSTD_CLEVEL
+unset ZSTD_NBTHREADS
+
+
die() {
println "$@" 1>&2
exit 1
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
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
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 "