Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: tools/test.py

Issue 11000052: tools/test.py: Add support for JUnit compatible XML output (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/test-wrapper-gypbuild.py » ('j') | tools/unittest_output.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/test.py
diff --git a/tools/test.py b/tools/test.py
index c361f937375dea768126005007b7ac12e1b180ab..6c0f64a72a7a088af0dd60a3b06f2b1bba97047c 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -43,8 +43,11 @@ import threading
import utils
from Queue import Queue, Empty
+from unittest_output import UnitTestOutput
VERBOSE = False
+XMLOUT = None
Jakob Kummerow 2012/09/28 17:38:52 No global variables. Please.
+XMLTESTSUITE = None
# ---------------------------------------------
@@ -66,6 +69,8 @@ class ProgressIndicator(object):
self.crashed = 0
self.terminate = False
self.lock = threading.Lock()
+ if XMLOUT:
Jakob Kummerow 2012/09/28 17:38:52 This looks weird. The UnitTestProgressIndicator is
+ self.xmlOutputter = UnitTestProgressIndicator()
def PrintFailureHeader(self, test):
if test.IsNegative():
@@ -80,6 +85,8 @@ class ProgressIndicator(object):
def Run(self, tasks):
self.Starting()
+ if XMLOUT:
+ self.xmlOutputter.Starting()
threads = []
# Spawn N-1 threads and then use this thread as the last one.
# That way -j1 avoids threading altogether which is a nice fallback
@@ -101,6 +108,8 @@ class ProgressIndicator(object):
# ...and then reraise the exception to bail out
raise
self.Done()
+ if XMLOUT:
+ self.xmlOutputter.Done()
return not self.failed
def RunSingle(self):
@@ -112,6 +121,8 @@ class ProgressIndicator(object):
case = test.case
self.lock.acquire()
self.AboutToRun(case)
+ if XMLOUT:
+ self.xmlOutputter.AboutToRun(case)
self.lock.release()
try:
start = time.time()
@@ -133,6 +144,8 @@ class ProgressIndicator(object):
self.succeeded += 1
self.remaining -= 1
self.HasRun(output)
+ if XMLOUT:
+ self.xmlOutputter.HasRun(output)
self.lock.release()
@@ -305,6 +318,47 @@ class MonochromeProgressIndicator(CompactProgressIndicator):
def ClearLine(self, last_line_length):
print ("\r" + (" " * last_line_length) + "\r"),
Jakob Kummerow 2012/09/28 17:38:52 nit: two newlines between top-level definitions
+class UnitTestProgressIndicator(ProgressIndicator):
+
+ def __init__(self):
+ self.outputter = UnitTestOutput(XMLTESTSUITE)
+ if XMLOUT:
+ self.outfile = open(XMLOUT, "w")
+ else:
+ self.outfile = sys.stdout
+
+ def Starting(self):
+ pass
+
+ def AboutToRun(self, case):
+ self.outputter.startNewTest(case.GetName())
+
+ def Done(self):
+ self.outputter.finishAndWrite(self.outfile)
+ if self.outfile != sys.stdout:
+ self.outfile.close()
+
+ def HasRun(self, output):
+ if output.UnexpectedOutput():
+ failtext = ""
+ stdout = output.output.stdout.strip()
+ if len(stdout):
+ failtext += "stdout:\n"
+ failtext += stdout
+ failtext += "\n"
+ stderr = output.output.stderr.strip()
+ if len(stderr):
+ failtext += "stderr:\n"
+ failtext += stderr
+ failtext += "\n"
+ if output.HasCrashed():
+ failtext += "--- CRASHED ---"
+ if output.HasTimedOut():
+ failtext += "--- TIMEOUT ---"
+ self.outputter.finishCurrentTest(output.command, True, failtext)
+ else:
+ self.outputter.finishCurrentTest(output.command, False)
+
PROGRESS_INDICATORS = {
'verbose': VerboseProgressIndicator,
@@ -1238,6 +1292,8 @@ def BuildOptions():
result.add_option("--no-store-unexpected-output",
help="Deletes the temporary JS files from tests that fails",
dest="store_unexpected_output", action="store_false")
+ result.add_option("--xmlout", help="File name of the UnitTest output")
+ result.add_option("--xmltestsuite", help="Name of the testsuite in the UnitTest XML output", default="v8tests")
result.add_option("--stress-only",
help="Only run tests with --always-opt --stress-opt",
default=False, action="store_true")
@@ -1291,6 +1347,11 @@ def ProcessOptions(options):
if options.mips_arch_variant:
options.scons_flags.append("mips_arch_variant=" + options.mips_arch_variant)
+ global XMLOUT
+ XMLOUT = options.xmlout
+ global XMLTESTSUITE
+ XMLTESTSUITE = options.xmltestsuite
+
if options.stress_only:
VARIANT_FLAGS = [['--stress-opt', '--always-opt']]
if options.nostress:
@@ -1552,4 +1613,8 @@ def Main():
if __name__ == '__main__':
- sys.exit(Main())
+ if XMLOUT:
+ Main()
+ sys.exit(0)
+ else:
+ sys.exit(Main())
« no previous file with comments | « no previous file | tools/test-wrapper-gypbuild.py » ('j') | tools/unittest_output.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698