forked from platformio/platformio-core
Rename source.file to source.file name and report project folder
This commit is contained in:
@ -29,7 +29,7 @@ class JsonTestReport(TestReportBase):
|
|||||||
output_path,
|
output_path,
|
||||||
"pio-test-report-%s-%s.json"
|
"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"),
|
datetime.datetime.now().strftime("%Y%m%d%H%M%S"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ class JsonTestReport(TestReportBase):
|
|||||||
def to_json(self):
|
def to_json(self):
|
||||||
result = dict(
|
result = dict(
|
||||||
version="1.0",
|
version="1.0",
|
||||||
name=self.test_result.name,
|
project_dir=self.test_result.project_dir,
|
||||||
duration=self.test_result.duration,
|
duration=self.test_result.duration,
|
||||||
testcase_nums=self.test_result.case_nums,
|
testcase_nums=self.test_result.case_nums,
|
||||||
error_nums=self.test_result.get_status_nums(TestStatus.ERRORED),
|
error_nums=self.test_result.get_status_nums(TestStatus.ERRORED),
|
||||||
@ -94,6 +94,6 @@ class JsonTestReport(TestReportBase):
|
|||||||
)
|
)
|
||||||
if test_case.source:
|
if test_case.source:
|
||||||
result["source"] = dict(
|
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
|
return result
|
||||||
|
@ -18,6 +18,7 @@ import xml.etree.ElementTree as ET
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
|
from platformio import __version__
|
||||||
from platformio.test.reports.base import TestReportBase
|
from platformio.test.reports.base import TestReportBase
|
||||||
from platformio.test.result import TestStatus
|
from platformio.test.result import TestStatus
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ class JunitTestReport(TestReportBase):
|
|||||||
output_path,
|
output_path,
|
||||||
"pio-test-report-%s-%s-junit.xml"
|
"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"),
|
datetime.datetime.now().strftime("%Y%m%d%H%M%S"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -42,7 +43,8 @@ class JunitTestReport(TestReportBase):
|
|||||||
|
|
||||||
def build_xml_tree(self):
|
def build_xml_tree(self):
|
||||||
root = ET.Element("testsuites")
|
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("tests", str(self.test_result.case_nums))
|
||||||
root.set("errors", str(self.test_result.get_status_nums(TestStatus.ERRORED)))
|
root.set("errors", str(self.test_result.get_status_nums(TestStatus.ERRORED)))
|
||||||
root.set("failures", str(self.test_result.get_status_nums(TestStatus.FAILED)))
|
root.set("failures", str(self.test_result.get_status_nums(TestStatus.FAILED)))
|
||||||
|
@ -49,8 +49,8 @@ class TestStatus(enum.Enum):
|
|||||||
|
|
||||||
|
|
||||||
class TestCaseSource:
|
class TestCaseSource:
|
||||||
def __init__(self, file, line=None):
|
def __init__(self, filename, line=None):
|
||||||
self.file = file
|
self.filename = filename
|
||||||
self.line = line
|
self.line = line
|
||||||
|
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ class TestCase:
|
|||||||
def humanize(self):
|
def humanize(self):
|
||||||
parts = []
|
parts = []
|
||||||
if self.source:
|
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)
|
parts.append(self.name)
|
||||||
if self.message:
|
if self.message:
|
||||||
parts.append(": " + self.message)
|
parts.append(": " + self.message)
|
||||||
@ -135,8 +135,8 @@ class TestSuite:
|
|||||||
|
|
||||||
|
|
||||||
class TestResult:
|
class TestResult:
|
||||||
def __init__(self, name):
|
def __init__(self, project_dir):
|
||||||
self.name = name
|
self.project_dir = project_dir
|
||||||
self._suites = []
|
self._suites = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -213,12 +213,12 @@ class TestRunnerBase:
|
|||||||
source = None
|
source = None
|
||||||
if "source_file" in data:
|
if "source_file" in data:
|
||||||
source = TestCaseSource(
|
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(
|
test_case = TestCase(
|
||||||
name=data.get("name"),
|
name=data.get("name").strip(),
|
||||||
status=TestStatus.from_string(data.get("status")),
|
status=TestStatus.from_string(data.get("status")),
|
||||||
message=data.get("message"),
|
message=data.get("message", "").strip() or None,
|
||||||
stdout=line,
|
stdout=line,
|
||||||
source=source,
|
source=source,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user