Skip to content

Commit ce2568e

Browse files
authored
(Chore): Add -vv logs for junit validation errors (#1054)
1 parent bddc7a9 commit ce2568e

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

context/src/junit/validator.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ pub fn validate(
225225
.into_iter()
226226
.for_each(|i| test_case_validation.add_issue(JunitValidationIssue::SubOptimal(i)));
227227

228+
if tracing::enabled!(tracing::Level::TRACE) {
229+
test_case_validation.issues().iter().for_each(|issue| {
230+
trace_test_case_validation_issue(
231+
issue,
232+
test_suite,
233+
test_case,
234+
&test_runner_report_for_validation,
235+
);
236+
});
237+
}
238+
228239
if test_case_validation.level != JunitValidationLevel::Invalid {
229240
valid_test_cases.push(test_case.clone());
230241
}
@@ -245,6 +256,34 @@ pub fn validate(
245256
super::bindings::BindingsJunitReportValidation::from(report_validation)
246257
}
247258

259+
fn trace_test_case_validation_issue(
260+
issue: &JunitTestCaseValidationIssue,
261+
test_suite: &BindingsTestSuite,
262+
test_case: &BindingsTestCase,
263+
test_runner_report: &Option<TestRunnerReport>,
264+
) {
265+
let test_case_extra = test_case.extra();
266+
let test_suite_extra = test_suite.extra();
267+
let file_or_filepath = test_case_extra
268+
.get(extra_attrs::FILE)
269+
.or(test_case_extra.get(extra_attrs::FILEPATH))
270+
.or(test_suite_extra.get(extra_attrs::FILE))
271+
.or(test_suite_extra.get(extra_attrs::FILEPATH))
272+
.map(String::as_str)
273+
.unwrap_or_default();
274+
275+
tracing::trace!(
276+
issue_message = %issue,
277+
test_suite_name = %test_suite.name,
278+
test_case_name = %test_case.name,
279+
test_case_classname = ?test_case.classname,
280+
test_case_file_or_filepath = %file_or_filepath,
281+
test_case_time = ?test_case.time,
282+
test_runner_label = test_runner_report.as_ref().and_then(|report| report.label.as_deref()),
283+
"junit testcase validation issue"
284+
);
285+
}
286+
248287
#[derive(Debug, Clone, Default)]
249288
pub struct JunitReportValidation {
250289
pub all_issues: Vec<JunitValidationIssueType>,

0 commit comments

Comments
 (0)