From: Theodore Ts'o Date: Sun, 9 Jun 2019 21:04:31 +0000 (-0400) Subject: report: gracefully handle XML report creation when no tests are run X-Git-Tag: v2022.05.01~1128 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ffdecf7498a1b04551bdee2fc7f8cadf513ce01f;p=users%2Fhch%2Fxfstests-dev.git report: gracefully handle XML report creation when no tests are run If no tests are run (because they have all been excluded) then make sure we insert a valid timestamp into the XML file, and avoid printing an error message when reading a non-existent test summary scratch file. Signed-off-by: Theodore Ts'o Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/common/report b/common/report index fb00b402c..6cac71fc8 100644 --- a/common/report +++ b/common/report @@ -59,6 +59,9 @@ _xunit_make_section_report() local report=$tmp.report.xunit.$sect_name.xml # Header echo "" > $REPORT_DIR/result.xml + if [ -z "$date_time" ]; then + date_time=$(date +"%F %T") + fi local dtime=`echo $date_time| tr " " 'T'` local stats="failures=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\"" local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" " @@ -70,7 +73,9 @@ _xunit_make_section_report() _xunit_add_property "$p" done echo -e "\t" >> $REPORT_DIR/result.xml - cat $tmp.report.xunit.$sect_name.xml >> $REPORT_DIR/result.xml + if [ -f $report ]; then + cat $report >> $REPORT_DIR/result.xml + fi echo "" >> $REPORT_DIR/result.xml echo "Xunit report: $REPORT_DIR/result.xml" }