-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more #7
more #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,9 +11,10 @@ | |||||||||||||||||||||||
from pathlib import Path | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
from phlop.app.cmake import list_tests as get_cmake_tests | ||||||||||||||||||||||||
from phlop.os import pushd | ||||||||||||||||||||||||
from phlop.os import env_sep | ||||||||||||||||||||||||
from phlop.proc import run | ||||||||||||||||||||||||
from phlop.reflection import classes_in_file | ||||||||||||||||||||||||
from phlop.sys import extend_sys_path | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
_LOG_DIR = Path(os.environ.get("PHLOP_LOG_DIR", os.getcwd())) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
@@ -25,6 +26,9 @@ class TestCase: | |||||||||||||||||||||||
working_dir: str = field(default_factory=lambda: None) | ||||||||||||||||||||||||
log_file_path: str = field(default_factory=lambda: None) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def __post_init__(self): | ||||||||||||||||||||||||
self.cmd = self.cmd.strip() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
class TestBatch: | ||||||||||||||||||||||||
def __init__(self, tests, cores=1): | ||||||||||||||||||||||||
|
@@ -101,13 +105,11 @@ def load_test_cases_in( | |||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def load_test_cases_from_cmake(ctest_test): | ||||||||||||||||||||||||
ppath = f"{ctest_test.working_dir}:{ctest_test.env.get('PYTHONPATH','')}" | ||||||||||||||||||||||||
ctest_test.env["PYTHONPATH"] = ppath | ||||||||||||||||||||||||
with pushd(ctest_test.working_dir): | ||||||||||||||||||||||||
print("ctest_test", ctest_test.cmd) | ||||||||||||||||||||||||
ppath = ctest_test.env.get("PYTHONPATH", "") | ||||||||||||||||||||||||
with extend_sys_path([ctest_test.working_dir] + ppath.split(env_sep())): | ||||||||||||||||||||||||
pyfile = ctest_test.cmd.split(" ")[-1] | ||||||||||||||||||||||||
return load_test_cases_in( | ||||||||||||||||||||||||
classes_in_file(pyfile, unittest.TestCase, fail_on_import_error=False), | ||||||||||||||||||||||||
classes_in_file(pyfile, unittest.TestCase, fail_on_import_error=True), | ||||||||||||||||||||||||
Comment on lines
+108
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The - with extend_sys_path([ctest_test.working_dir] + ppath.split(env_sep())):
+ with extend_sys_path([ctest_test.working_dir] + (ppath.split(env_sep()) if ppath else [])): Committable suggestion
Suggested change
|
||||||||||||||||||||||||
env=ctest_test.env, | ||||||||||||||||||||||||
working_dir=ctest_test.working_dir, | ||||||||||||||||||||||||
log_file_path=_LOG_DIR | ||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
extend_env
function clears and then restores the entire environment. This could lead to race conditions in a multi-threaded context where other threads might see an empty or partially restored environment.Committable suggestion