diff options
author | Gregory Brail <greg@apigee.com> | 2015-01-21 17:43:56 -0800 |
---|---|---|
committer | Gregory Brail <greg@apigee.com> | 2015-02-26 16:46:59 -0800 |
commit | 41ed1257d77cfe87bf2747801c473b5b681c62b1 (patch) | |
tree | 1c7faaa9c432d63919909e6b6e2cbb10d44933c1 /tools/packaging | |
parent | d075338699cc8eaf123d5f5491f0d68116ee224a (diff) |
Fix JUnit output so that it can be actually be parsed by JUnit and
Jenkins. Wrap XML output correctly and
post-process failure messages to avoid invalid XML characters.
Diffstat (limited to 'tools/packaging')
-rwxr-xr-x | tools/packaging/test262.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/packaging/test262.py b/tools/packaging/test262.py index 9a5481827..b9172b067 100755 --- a/tools/packaging/test262.py +++ b/tools/packaging/test262.py @@ -170,6 +170,15 @@ class TestResult(object): if len(err) > 0: target.write("--- errors --- \n %s" % err) + # This is a way to make the output from the "whitespace" tests into valid XML + def SafeFormat(self, msg): + try: + msg = msg.encode(encoding='ascii', errors='strict') + msg = msg.replace('\u000Bx', '?') + msg = msg.replace('\u000Cx', '?') + except: + return 'Output contained invalid characters' + def XmlAssemble(self, result): test_name = self.case.GetName() test_mode = self.case.GetMode() @@ -182,9 +191,9 @@ class TestResult(object): out = self.stdout.strip().decode('utf-8') err = self.stderr.strip().decode('utf-8') if len(out) > 0: - failureElement.text = out + failureElement.text = self.SafeFormat(out) if len(err) > 0: - failureElement.text = err + failureElement.text = self.SafeFormat(err) testCaseElement.append(failureElement) return testCaseElement @@ -520,7 +529,9 @@ class TestSuite(object): self.logf = open(logname, "w") if junitfile: self.outfile = open(junitfile, "w") + TestSuitesElement = xmlj.Element("testsuites") TestSuiteElement = xmlj.Element("testsuite") + TestSuitesElement.append(TestSuiteElement) TestSuiteElement.attrib["name "] = "test262" for x in range(len(EXCLUDE_LIST)): if self.ShouldRun (unicode(EXCLUDE_LIST[x].encode('utf-8','ignore')), tests): @@ -538,7 +549,7 @@ class TestSuite(object): TestCaseElement = result.XmlAssemble(result) TestSuiteElement.append(TestCaseElement) if case == cases[len(cases)-1]: - xmlj.ElementTree(TestSuiteElement).write(junitfile, "UTF-8") + xmlj.ElementTree(TestSuitesElement).write(junitfile, "UTF-8") if logname: self.WriteLog(result) progress.HasRun(result) |