Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/software/field_tests/field_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 6 additions & 12 deletions src/software/simulated_tests/simulated_test_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading