diff --git a/test/case/all.yaml b/test/case/all.yaml index 12edc8c2..70869445 100644 --- a/test/case/all.yaml +++ b/test/case/all.yaml @@ -1,4 +1,5 @@ --- +- case: meta/reproducible.py - case: meta/wait.py - name: Misc tests diff --git a/test/case/meta/reproducible.py b/test/case/meta/reproducible.py new file mode 100755 index 00000000..6e2ad565 --- /dev/null +++ b/test/case/meta/reproducible.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +import os + +import infamy + +with infamy.Test() as test: + with test.step("$PYTHONHASHSEED is set"): + seed = os.environ.get("PYTHONHASHSEED") + if seed == None: + print("$PYTHONHASHSEED must be set in order to create a reproducible test environment") + test.fail() + else: + print(f"Specify PYTHONHASHSEED={seed} to reproduce this test environment") + + test.succeed() diff --git a/test/env b/test/env index 72d95b59..06268372 100755 --- a/test/env +++ b/test/env @@ -157,6 +157,7 @@ if [ "$containerize" ]; then --cap-add=NET_RAW \ --cap-add=NET_ADMIN \ --device=/dev/net/tun \ + --env PYTHONHASHSEED=${PYTHONHASHSEED:-$(shuf -i 0-$(((1 << 32) - 1)) -n 1)} \ --env VIRTUAL_ENV_DISABLE_PROMPT=yes \ --env PROMPT_DIRTRIM="$ixdir" \ --env PS1='\e[1m$(date "+%H:%M:%S") \h\e[0m:\W # ' \