-
-
Notifications
You must be signed in to change notification settings - Fork 685
Expand file tree
/
Copy pathtoolchain_runs_test.py
More file actions
38 lines (31 loc) · 1.15 KB
/
toolchain_runs_test.py
File metadata and controls
38 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import pathlib
import platform
import sys
import unittest
from python.runfiles import runfiles
class RunTest(unittest.TestCase):
def test_ran(self):
rf = runfiles.Create()
settings_path = rf.Rlocation(
"rules_python/tests/support/current_build_settings.json"
)
settings = json.loads(pathlib.Path(settings_path).read_text())
if platform.system() == "Windows":
self.assertEqual(
"/_magic_pyruntime_sentinel_do_not_use", settings["interpreter_path"]
)
else:
self.assertIn(
"runtime_env_toolchain_interpreter.sh",
settings["interpreter"]["short_path"],
)
if settings["bootstrap_impl"] == "script":
# Verify we're running in a venv
self.assertNotEqual(sys.prefix, sys.base_prefix)
# .venv/ occurs for a build-time venv.
# For a runtime created venv, it goes into a temp dir, so
# look for the /bin/ dir as an indicator.
self.assertRegex(sys.executable, r"[.]venv/|/bin/")
if __name__ == "__main__":
unittest.main()