Skip to content

Commit 1acbb0d

Browse files
Fix cobertura_report collection error because of earlier error, before tests (#487)
CoberturaPublisher is done at the end of the execution because it cannot be duplicated (at least it was the case several years ago when it was plugged-in). With 1f3c17d / #482 we tried to eagerly collect tests results even when tests failed, but didn't properly handle that late collection in the case of errors before any test step: the tests results won't exist. Because it's a global, late collection, we cannot do the fancy double collection with/without error propagation that we did in #482 for the other tests results collections. That's OK; the situation is explained to the user.
1 parent 56637e0 commit 1acbb0d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

dmake/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,15 @@ def write_line(data):
664664
indent_level += 1
665665

666666
if emit_cobertura:
667+
write_line("try {")
668+
indent_level += 1
667669
write_line("step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '%s/**/*.xml', failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])" % (cobertura_tests_results_dir))
668670
write_line("publishCoverage adapters: [coberturaAdapter(mergeToOneReport: true, path: '%s/**/*.xml')], calculateDiffForChangeRequests: true, sourceFileResolver: sourceFiles('NEVER_STORE')" % (cobertura_tests_results_dir))
669671
write_line('''sh('rm -rf "%s"')''' % cobertura_tests_results_dir)
672+
indent_level -= 1
673+
write_line("} catch (error) {")
674+
write_line(" dmake_echo 'Late cobertura_report test result collection failed, it may be because the test steps were not reached (earlier error: check logs/steps above/before), or because the cobertura_report is misconfigured (check the path config).'")
675+
write_line("}")
670676

671677
write_line('sh("dmake_clean")')
672678
indent_level -= 1

0 commit comments

Comments
 (0)