diff --git a/platformio/test/reports/json.py b/platformio/test/reports/json.py index 67e6c3a7..dd39f5f4 100644 --- a/platformio/test/reports/json.py +++ b/platformio/test/reports/json.py @@ -29,7 +29,7 @@ class JsonTestReport(TestReportBase): output_path, "pio-test-report-%s-%s.json" % ( - self.test_result.name, + os.path.basename(self.test_result.project_dir), datetime.datetime.now().strftime("%Y%m%d%H%M%S"), ), ) @@ -43,7 +43,7 @@ class JsonTestReport(TestReportBase): def to_json(self): result = dict( version="1.0", - name=self.test_result.name, + project_dir=self.test_result.project_dir, duration=self.test_result.duration, testcase_nums=self.test_result.case_nums, error_nums=self.test_result.get_status_nums(TestStatus.ERRORED), @@ -94,6 +94,6 @@ class JsonTestReport(TestReportBase): ) if test_case.source: result["source"] = dict( - file=test_case.source.file, line=test_case.source.line + filename=test_case.source.filename, line=test_case.source.line ) return result diff --git a/platformio/test/reports/junit.py b/platformio/test/reports/junit.py index 9308aed7..64af9b55 100644 --- a/platformio/test/reports/junit.py +++ b/platformio/test/reports/junit.py @@ -18,6 +18,7 @@ import xml.etree.ElementTree as ET import click +from platformio import __version__ from platformio.test.reports.base import TestReportBase from platformio.test.result import TestStatus @@ -29,7 +30,7 @@ class JunitTestReport(TestReportBase): output_path, "pio-test-report-%s-%s-junit.xml" % ( - self.test_result.name, + os.path.basename(self.test_result.project_dir), datetime.datetime.now().strftime("%Y%m%d%H%M%S"), ), ) @@ -42,7 +43,8 @@ class JunitTestReport(TestReportBase): def build_xml_tree(self): root = ET.Element("testsuites") - root.set("name", self.test_result.name) + root.set("name", self.test_result.project_dir) + root.set("platformio_version", __version__) root.set("tests", str(self.test_result.case_nums)) root.set("errors", str(self.test_result.get_status_nums(TestStatus.ERRORED))) root.set("failures", str(self.test_result.get_status_nums(TestStatus.FAILED))) diff --git a/platformio/test/result.py b/platformio/test/result.py index 5f1edbc0..b6e02803 100644 --- a/platformio/test/result.py +++ b/platformio/test/result.py @@ -49,8 +49,8 @@ class TestStatus(enum.Enum): class TestCaseSource: - def __init__(self, file, line=None): - self.file = file + def __init__(self, filename, line=None): + self.filename = filename self.line = line @@ -79,7 +79,7 @@ class TestCase: def humanize(self): parts = [] if self.source: - parts.append("%s:%d: " % (self.source.file, self.source.line)) + parts.append("%s:%d: " % (self.source.filename, self.source.line)) parts.append(self.name) if self.message: parts.append(": " + self.message) @@ -135,8 +135,8 @@ class TestSuite: class TestResult: - def __init__(self, name): - self.name = name + def __init__(self, project_dir): + self.project_dir = project_dir self._suites = [] @property diff --git a/platformio/test/runners/base.py b/platformio/test/runners/base.py index ff28803a..eb13ca2a 100644 --- a/platformio/test/runners/base.py +++ b/platformio/test/runners/base.py @@ -213,12 +213,12 @@ class TestRunnerBase: source = None if "source_file" in data: source = TestCaseSource( - file=data["source_file"], line=int(data.get("source_line")) + filename=data["source_file"], line=int(data.get("source_line")) ) test_case = TestCase( - name=data.get("name"), + name=data.get("name").strip(), status=TestStatus.from_string(data.get("status")), - message=data.get("message"), + message=data.get("message", "").strip() or None, stdout=line, source=source, )