From 4d4aec4f570262456ce7d9bc5bb88b10168e47dd Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Tue, 13 Dec 2022 19:36:41 +0200 Subject: [PATCH] Export test suite directory --- platformio/test/cli.py | 6 +++--- platformio/test/helpers.py | 14 +++++++++++++- platformio/test/reports/json.py | 1 + platformio/test/result.py | 3 ++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/platformio/test/cli.py b/platformio/test/cli.py index 1e456d4d..d0a6e53a 100644 --- a/platformio/test/cli.py +++ b/platformio/test/cli.py @@ -156,9 +156,6 @@ def cli( # pylint: disable=too-many-arguments,too-many-locals,redefined-builtin runner.start(ctx) print_suite_footer(test_suite) - # Reset custom project config - app.set_session_var("custom_project_conf", None) - stdout_report = TestReportFactory.new("stdout", test_result) stdout_report.generate(verbose=verbose or list_tests) @@ -171,6 +168,9 @@ def cli( # pylint: disable=too-many-arguments,too-many-locals,redefined-builtin custom_report = TestReportFactory.new(output_format, test_result) custom_report.generate(output_path=output_path, verbose=True) + # Reset custom project config + app.set_session_var("custom_project_conf", None) + if test_result.is_errored or test_result.get_status_nums(TestStatus.FAILED): raise exception.ReturnErrorCode(1) diff --git a/platformio/test/helpers.py b/platformio/test/helpers.py index 908173d0..01650a0b 100644 --- a/platformio/test/helpers.py +++ b/platformio/test/helpers.py @@ -35,6 +35,7 @@ def list_test_names(project_config): def list_test_suites(project_config, environments, filters, ignores): result = [] + test_dir = project_config.get("platformio", "test_dir") default_envs = project_config.default_envs() test_names = list_test_names(project_config) for env_name in project_config.envs(): @@ -58,5 +59,16 @@ def list_test_suites(project_config, environments, filters, ignores): test_name != "*" and any(fnmatch(test_name, p) for p in patterns["ignore"]), ] - result.append(TestSuite(env_name, test_name, finished=any(skip_conditions))) + result.append( + TestSuite( + env_name, + test_name, + finished=any(skip_conditions), + test_dir=os.path.abspath( + test_dir + if test_name == "*" + else os.path.join(test_dir, test_name) + ), + ) + ) return result diff --git a/platformio/test/reports/json.py b/platformio/test/reports/json.py index c22fb587..791224c7 100644 --- a/platformio/test/reports/json.py +++ b/platformio/test/reports/json.py @@ -59,6 +59,7 @@ class JsonTestReport(TestReportBase): result = dict( env_name=test_suite.env_name, test_name=test_suite.test_name, + test_dir=test_suite.test_dir, status=test_suite.status.name, duration=test_suite.duration, timestamp=datetime.datetime.fromtimestamp(test_suite.timestamp).strftime( diff --git a/platformio/test/result.py b/platformio/test/result.py index b2000b2e..091fa964 100644 --- a/platformio/test/result.py +++ b/platformio/test/result.py @@ -93,9 +93,10 @@ class TestCase: class TestSuite: - def __init__(self, env_name, test_name, finished=False): + def __init__(self, env_name, test_name, finished=False, test_dir=None): self.env_name = env_name self.test_name = test_name + self.test_dir = test_dir self.timestamp = 0 self.duration = 0 self._cases = []