diff --git a/context-js/tests/parse_and_validate.test.ts b/context-js/tests/parse_and_validate.test.ts index 7e55ed15..8da1d491 100644 --- a/context-js/tests/parse_and_validate.test.ts +++ b/context-js/tests/parse_and_validate.test.ts @@ -68,6 +68,8 @@ describe("context-js", () => { + + @@ -101,6 +103,23 @@ describe("context-js", () => { .all_issues_owned() .filter((issue) => issue.error_type === JunitValidationType.Report), ).toHaveLength(1); + + const nestedJunitXml = ` + + + + + + + + + + `; + + report = junit_parse(Buffer.from(nestedJunitXml, "utf-8")); + junitReportValidation = junit_validate(report[0]); + + expect(junitReportValidation.max_level()).toBe(JunitValidationLevel.Valid); }); it("validates repos", () => { diff --git a/context-py/tests/test_junit_parse.py b/context-py/tests/test_junit_parse.py index beb7ec0f..44062604 100644 --- a/context-py/tests/test_junit_parse.py +++ b/context-py/tests/test_junit_parse.py @@ -19,7 +19,8 @@ def test_junit_parse_valid(): FAILURE BODY - + + @@ -86,22 +87,26 @@ def test_junit_parse_broken_xml(): def test_junit_parse_nested_testsuites(): import typing as PT + from datetime import datetime, timezone from context_py import BindingsReport, BindingsTestCaseStatusStatus, junit_parse - nested_testsuites_xml = b""" + valid_timestamp = datetime.now().astimezone(timezone.utc).isoformat() + + nested_testsuites_xml = f""" - - - - - - - - - """ - - reports: PT.List[BindingsReport] = junit_parse(nested_testsuites_xml) + + + + + + + + + + """ + + reports: PT.List[BindingsReport] = junit_parse(str.encode(nested_testsuites_xml)) assert len(reports) == 1 report = reports[0] diff --git a/context/src/junit/parser.rs b/context/src/junit/parser.rs index 1632e1ba..5059c6e8 100644 --- a/context/src/junit/parser.rs +++ b/context/src/junit/parser.rs @@ -38,8 +38,6 @@ pub enum JunitParseError { ReportMultipleFound, #[error("report end tag found without start tag")] ReportStartTagNotFound, - #[error("could not parse test suite name")] - TestSuiteName, #[error("test suite end tag found without start tag")] TestSuiteStartTagNotFound, #[error("could not parse test case name")] @@ -54,12 +52,6 @@ pub enum JunitParseError { TestRerunStartTagNotFound, #[error("test rerun end tag found without start tag")] TestRerunTestCaseNotFound, - #[error("system out is empty")] - SystemOutEmpty, - #[error("system err is empty")] - SystemErrEmpty, - #[error("stack trace is empty")] - StackTraceEmpty, } #[derive(Debug, Clone)] @@ -213,9 +205,6 @@ impl JunitParser { self.open_test_rerun(&e); self.close_test_rerun(); } - TAG_TEST_RERUN_STACK_TRACE => self.errors.push(JunitParseError::StackTraceEmpty), - TAG_SYSTEM_OUT => self.errors.push(JunitParseError::SystemOutEmpty), - TAG_SYSTEM_ERR => self.errors.push(JunitParseError::SystemErrEmpty), _ => (), }, Event::CData(e) => { @@ -295,9 +284,6 @@ impl JunitParser { } let test_suite_name = parse_attr::name(e).unwrap_or_default(); - if test_suite_name.is_empty() { - self.errors.push(JunitParseError::TestSuiteName); - }; let mut test_suite = TestSuite::new(test_suite_name); if let Some(timestamp) = parse_attr::timestamp(e, &mut self.date_parser) {