From 6c083cd82c75e8f20af859e30cafea34cdc838b6 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Thu, 15 Aug 2024 13:17:47 -0700 Subject: [PATCH] add basic test --- tests/base_rules/BUILD.bazel | 15 +++++++++++++++ .../base_rules/inherit_pythonsafepath_env_test.sh | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/base_rules/BUILD.bazel b/tests/base_rules/BUILD.bazel index cd5771533d..73ec3a2561 100644 --- a/tests/base_rules/BUILD.bazel +++ b/tests/base_rules/BUILD.bazel @@ -78,3 +78,18 @@ sh_py_run_test( sh_src = "inherit_pythonsafepath_env_test.sh", target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT, ) + +sh_py_run_test( + name = "pythonsafepath_env_system_python_zip_no_test", + bootstrap_impl = "system_python", + build_python_zip = "no", + py_src = "bin.py", + # todo: rename sh file + sh_src = "inherit_pythonsafepath_env_test.sh", +) + +# todo: add tests for: +# bootstrap={system,script} x zip={yes,no} + +# todo: add test for Python 3.9 (or lower, before -P flag is available); +# could be an analysis test instead of regular test, since 3.9 is so old. diff --git a/tests/base_rules/inherit_pythonsafepath_env_test.sh b/tests/base_rules/inherit_pythonsafepath_env_test.sh index bc6e2d53f3..61d4a051e8 100755 --- a/tests/base_rules/inherit_pythonsafepath_env_test.sh +++ b/tests/base_rules/inherit_pythonsafepath_env_test.sh @@ -59,11 +59,11 @@ actual=$(PYTHONSAFEPATH=OUTER $bin 2>&1) expect_match "sys.flags.safe_path: True" "$actual" expect_match "PYTHONSAFEPATH: OUTER" "$actual" -echo "Check enabled by default" +echo "Check enabled by default without PYTHONSAFEPATH env contamination" # Verifying doing nothing leaves safepath enabled by default actual=$($bin 2>&1) expect_match "sys.flags.safe_path: True" "$actual" -expect_match "PYTHONSAFEPATH: 1" "$actual" +expect_match "PYTHONSAFEPATH: UNSET" "$actual" # Exit if any of the expects failed [[ ! -e EXPECTATION_FAILED ]]