Hack: add one empty test case to the empty results.
authorIgor Stoppa <igor.stoppa@intel.com>
Wed, 14 Jan 2015 10:40:46 +0000 (12:40 +0200)
committerXu Chang <changx.xu@intel.com>
Tue, 20 Jan 2015 08:48:03 +0000 (16:48 +0800)
Jenkins will not consider the empty results.xml if it is
completely devoid of test results, so an empty test case is added.

Change-Id: I58cddf30ae5207be24fb751c9b373ae5846d4ffb

job_test_build.py

index 5feed99..6f7e026 100755 (executable)
@@ -83,9 +83,15 @@ def create_empty_results():
     try:
         os.makedirs(results_folder)
         with open(os.path.join(results_folder, "results.xml"), "w") as res:
+            # Note: XXX
+            # Jenkins will not accept a results.xml as valid JUnit file
+            # unless it contains at least one testcase, even if empty.
+            # Without it, the build will be marked as FAILED, which is
+            # incorrect in some cases, ex: unsupported image.
             res.write('<?xml version="1.0" encoding="utf-8"?>\n'
                       '<testsuite errors="0" failures="0" '
                       'name="none" skips="0" tests="0" time="0">\n'
+                      '<testcase />\n'
                       '</testsuite>\n')
     except OSError:
         logging.critical("Cannot create empty directory: " + results_folder)