[unit-tests] Emit NUnit xml report of test result
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Fri, 18 Sep 2015 17:37:10 +0000 (19:37 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Sun, 20 Sep 2015 00:44:14 +0000 (02:44 +0200)
Overrides check-local to output an NUnit report of the test results.

It currently creates a single pass/fail test case as this is the easiest solution,
but the test log is included in the report which should be enough to diagnose errors.

Parallelism is disabled here since we need to ensure check-local happens after check
so we can parse test-suite.log. The tests are quite fast so it doesn't hurt much.

We need AUTOMAKE_OPTIONS=parallel-tests so the test-suite.log gets created on automake 1.11.

mono/unit-tests/Makefile.am

index 2c2369589e143fde0125a2b1ca09046b99620031..a19e543e091ab29f1f1eb075812f21e0cae6cb15 100644 (file)
@@ -7,6 +7,7 @@ if PLATFORM_DARWIN
 test_ldflags = -framework CoreFoundation -framework Foundation
 endif
 
+AUTOMAKE_OPTIONS = parallel-tests
 
 if !CROSS_COMPILE
 if !HOST_WIN32
@@ -40,6 +41,14 @@ noinst_PROGRAMS = test-sgen-qsort test-memfuncs test-mono-linked-list-set test-c
 
 TESTS = test-sgen-qsort test-memfuncs test-mono-linked-list-set test-conc-hashtable
 
+.NOTPARALLEL:
+
+check-local:
+       if grep -q "# FAIL:  0\|tests passed" test-suite.log; then successbool=True && failures=0; else successbool=False && failures=1; fi; \
+       echo "<?xml version='1.0' encoding='utf-8'?><test-results failures='$$failures' total='1' not-run='0' name='unit-tests.dummy' date='$$(date +%F)' time='$$(date +%T)'><test-suite name='MonoTests.unit-tests' success='$$successbool' time='0'><results><test-case name='MonoTests.unit-tests.100percentsuccess' executed='True' success='$$successbool' time='0'>" > TestResult-unit-tests.xml; \
+       if [ $$failures -ne 0 ]; then echo "<failure><message>"'<![CDATA[' >> TestResult-unit-tests.xml && cat test-suite.log >> TestResult-unit-tests.xml && echo "]]></message><stack-trace></stack-trace></failure>" >> TestResult-unit-tests.xml; fi; \
+       echo "</test-case></results></test-suite></test-results>" >> TestResult-unit-tests.xml
+
 endif SUPPORT_BOEHM
 endif !HOST_WIN32
 endif !CROSS_COMPILE