Skip to contentSkip to conversation

report: gracefully handle XML report creation when no tests are run

PATCH RESEND In review Theodore Ts'o 2 participants 2 messages Jun 9, 2019 – Jun 16, 2019

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 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.

---

I sent this a while back, and didn't get any comments, so I'm resending. PTAL.

 common/report | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/report +6 -1
index fb00b402..6cac71fc 100644
@@ -59,6 +59,9 @@ _xunit_make_section_report()
 	local report=$tmp.report.xunit.$sect_name.xml
 	# Header
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $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</properties>" >> $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 "</testsuite>" >> $REPORT_DIR/result.xml
 	echo "Xunit report: $REPORT_DIR/result.xml"
 }
Signature · 1 line
2.22.0
#1 lore raw
Quoted 9 lines · Theodore Ts'o

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.

---

I sent this a while back, and didn't get any comments, so I'm resending. PTAL.

Sorry, I totally missed it.. applied now, thanks!

Eryu

Quoted 32 lines
 common/report | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/report +6 -1
index fb00b402..6cac71fc 100644
@@ -59,6 +59,9 @@ _xunit_make_section_report()
 	local report=$tmp.report.xunit.$sect_name.xml
 	# Header
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $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</properties>" >> $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 "</testsuite>" >> $REPORT_DIR/result.xml
 	echo "Xunit report: $REPORT_DIR/result.xml"
 }
Signature · 1 line
2.22.0