diff --git a/src/software/field_tests/field_test_fixture.py b/src/software/field_tests/field_test_fixture.py index c23a4fdbf8..fe3d9eb992 100644 --- a/src/software/field_tests/field_test_fixture.py +++ b/src/software/field_tests/field_test_fixture.py @@ -204,25 +204,19 @@ def excepthook(args): def get_runtime_dir(): """Gets the base runtime directory for the test execution. + TODO: Refactor #3744 - If running under Bazel, it uses TEST_TMPDIR to keep tests isolated. To prevent UNIX - socket path length limits from being exceeded by Bazel's long paths, it creates a short - symlink in /tmp to the TEST_TMPDIR. + Creates a new persistent directory for each test so that tests + running in parallel do not interfere with each other. :return: The path to the runtime directory. """ - test_tmpdir = os.environ.get("TEST_TMPDIR") - if not test_tmpdir: - return "/tmp/tbots" import uuid - symlink_path = os.path.join("/tmp", f"tbt_{uuid.uuid4().hex[:8]}") - try: - os.symlink(test_tmpdir, symlink_path) - except OSError: - pass - return symlink_path + runtime_dir = os.path.join("/tmp", f"tbots_{uuid.uuid4().hex[:8]}") + os.makedirs(runtime_dir, exist_ok=True) + return runtime_dir RUNTIME_DIR = get_runtime_dir() diff --git a/src/software/simulated_tests/simulated_test_fixture.py b/src/software/simulated_tests/simulated_test_fixture.py index 1edf1c7ebc..6b4dd49dab 100644 --- a/src/software/simulated_tests/simulated_test_fixture.py +++ b/src/software/simulated_tests/simulated_test_fixture.py @@ -421,25 +421,19 @@ def run_test( def get_runtime_dir(): """Gets the base runtime directory for the test execution. + TODO: Refactor #3744 - If running under Bazel, it uses TEST_TMPDIR to keep tests isolated. To prevent UNIX - socket path length limits from being exceeded by Bazel's long paths, it creates a short - symlink in /tmp to the TEST_TMPDIR. + Creates a new persistent directory for each test so that tests + running in parallel do not interfere with each other. :return: The path to the runtime directory. """ - test_tmpdir = os.environ.get("TEST_TMPDIR") - if not test_tmpdir: - return "/tmp/tbots" import uuid - symlink_path = os.path.join("/tmp", f"tbt_{uuid.uuid4().hex[:8]}") - try: - os.symlink(test_tmpdir, symlink_path) - except OSError: - pass - return symlink_path + runtime_dir = os.path.join("/tmp", f"tbots_{uuid.uuid4().hex[:8]}") + os.makedirs(runtime_dir, exist_ok=True) + return runtime_dir RUNTIME_DIR = get_runtime_dir()