Export test suite directory

This commit is contained in:
Ivan Kravets
2022-12-13 19:36:41 +02:00
parent 7bbfaab891
commit 4d4aec4f57
4 changed files with 19 additions and 5 deletions

View File

@ -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)

View File

@ -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

View File

@ -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(

View File

@ -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 = []