Bug 491784 - runxpcshelltests.py should generate a count summary, as reftest and mochitest do; (Av1a-191) Just do it, plus followup fix for bug 485736; r=ted.mielczarek
authorSerge Gautherie <sgautherie.bz@free.fr>
Sat, 01 Aug 2009 00:19:25 +0200
changeset 26182 83d2f8008e677e0a9063e98c018833fe11e8e757
parent 26178 017b8cd48bedcd54d19ca515f59b27e055fd9ba0
child 26183 261a0fa4249d1bf80b2975a57a8c2f5ccc350cf6
push id1844
push usersgautherie.bz@free.fr
push dateFri, 31 Jul 2009 22:34:07 +0000
reviewersted.mielczarek
bugs491784, 485736
milestone1.9.1.3pre
Bug 491784 - runxpcshelltests.py should generate a count summary, as reftest and mochitest do; (Av1a-191) Just do it, plus followup fix for bug 485736; r=ted.mielczarek
config/rules.mk
js/src/config/rules.mk
testing/xpcshell/runxpcshelltests.py
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -163,26 +163,26 @@ xpcshell-tests:
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE), but don't automatically
 # start the test. Instead, present the xpcshell prompt so the user can
 # attach a debugger and then start the test.
 check-interactive:
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
-          --test=$(SOLO_FILE) \
+          --test-path=$(SOLO_FILE) \
           --interactive \
           $(DIST)/bin/xpcshell \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE)
 check-one:
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
-          --test=$(SOLO_FILE) \
+          --test-path=$(SOLO_FILE) \
           $(DIST)/bin/xpcshell \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -163,26 +163,26 @@ xpcshell-tests:
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE), but don't automatically
 # start the test. Instead, present the xpcshell prompt so the user can
 # attach a debugger and then start the test.
 check-interactive:
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
-          --test=$(SOLO_FILE) \
+          --test-path=$(SOLO_FILE) \
           --interactive \
           $(DIST)/bin/xpcshell \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE)
 check-one:
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
-          --test=$(SOLO_FILE) \
+          --test-path=$(SOLO_FILE) \
           $(DIST)/bin/xpcshell \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -72,16 +72,19 @@ def runTests(xpcshell, testdirs=[], xreP
     instead of automatically executing the test.
   """
 
   if not testdirs and not manifest:
     # nothing to test!
     print >>sys.stderr, "Error: No test dirs or test manifest specified!"
     return False
 
+  passCount = 0
+  failCount = 0
+
   testharnessdir = os.path.dirname(os.path.abspath(__file__))
   xpcshell = os.path.abspath(xpcshell)
   # we assume that httpd.js lives in components/ relative to xpcshell
   httpdJSPath = os.path.join(os.path.dirname(xpcshell), "components", "httpd.js").replace("\\", "/");
 
   env = dict(os.environ)
   # Make assertions fatal
   env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
@@ -164,17 +167,16 @@ def runTests(xpcshell, testdirs=[], xreP
       # Path only.
       # Simply remove optional ending separator.
       testPath = testPath.rstrip("/")
 
   if manifest is not None:
     testdirs = readManifest(os.path.abspath(manifest))
 
   # Process each test directory individually.
-  success = True
   for testdir in testdirs:
     if testPath and not testdir.endswith(testPath):
       continue
 
     testdir = os.path.abspath(testdir)
 
     # get the list of head and tail files from the directory
     testHeadFiles = []
@@ -218,19 +220,20 @@ def runTests(xpcshell, testdirs=[], xreP
         # not sure what else to do here...
         return True
 
       if proc.returncode != 0 or (stdout is not None and re.search("^TEST-UNEXPECTED-FAIL", stdout, re.MULTILINE)):
         print """TEST-UNEXPECTED-FAIL | %s | test failed (with xpcshell return code: %d), see following log:
   >>>>>>>
   %s
   <<<<<<<""" % (test, proc.returncode, stdout)
-        success = False
+        failCount += 1
       else:
         print "TEST-PASS | %s | test passed" % test
+        passCount += 1
 
       leakReport = processLeakLog(leakLogFile)
 
       if stdout is not None:
         try:
           f = open(test + '.log', 'w')
           f.write(stdout)
           if leakReport:
@@ -239,17 +242,25 @@ def runTests(xpcshell, testdirs=[], xreP
           if f:
             f.close()
 
       # Remove the leak detection file (here) so it can't "leak" to the next test.
       # The file is not there if leak logging was not enabled in the xpcshell build.
       if os.path.exists(leakLogFile):
         os.remove(leakLogFile)
 
-  return success
+  if passCount == 0 and failCount == 0:
+    print "TEST-UNEXPECTED-FAIL | runxpcshelltests.py | No tests run. Did you pass an invalid --test-path?"
+    failCount = 1
+
+  print """INFO | Result summary:
+INFO | Passed: %d
+INFO | Failed: %d""" % (passCount, failCount)
+
+  return failCount == 0
 
 def main():
   """Process command line arguments and call runTests() to do the real work."""
   parser = OptionParser()
   parser.add_option("--xre-path",
                     action="store", type="string", dest="xrePath", default=None,
                     help="absolute path to directory containing XRE (probably xulrunner)")
   parser.add_option("--test-path",