Bug 484298: Need to be able to see logs from xpcshell tests. r=ted
authorjag <jag@tty.nl>
Tue, 02 Jun 2009 16:39:51 +0200
changeset 25849 51450142f83bd24a0bc9c88343f4e9f2e8eb612e
parent 25848 24f007882aff83e04924b66f11df82fae8fc92ca
child 25850 141f4f658ce3e891ac648dc3a0cbbdde48fda9f0
push id1634
push usersgautherie.bz@free.fr
push dateTue, 02 Jun 2009 14:40:25 +0000
reviewersted
bugs484298
milestone1.9.1pre
Bug 484298: Need to be able to see logs from xpcshell tests. r=ted
testing/xpcshell/runxpcshelltests.py
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -89,28 +89,28 @@ def runTests(xpcshell, testdirs=[], xreP
   # Each test will overwrite it.
   leakLogFile = os.path.join(tempfile.gettempdir(), "runxpcshelltests_leaks.log")
   env["XPCOM_MEM_LEAK_LOG"] = leakLogFile
 
   def processLeakLog(leakLogFile):
     """Process the leak log."""
     # For the time being, don't warn (nor "info") if the log file is not there. (Bug 469523)
     if not os.path.exists(leakLogFile):
-      return
+      return None
 
     leaks = open(leakLogFile, "r")
     leakReport = leaks.read()
     leaks.close()
 
     # Only check whether an actual leak was reported.
-    if not "0 TOTAL " in leakReport:
-      return
+    if "0 TOTAL " in leakReport:
+      # For the time being, simply copy the log. (Bug 469523)
+      print leakReport.rstrip("\n")
 
-    # For the time being, simply copy the log. (Bug 469523)
-    print leakReport.rstrip("\n")
+    return leakReport
 
   if xrePath is None:
     xrePath = os.path.dirname(xpcshell)
   else:
     xrePath = os.path.abspath(xrePath)
   if sys.platform == 'win32':
     env["PATH"] = env["PATH"] + ";" + xrePath
   elif sys.platform == 'osx':
@@ -199,17 +199,28 @@ def runTests(xpcshell, testdirs=[], xreP
       if proc.returncode != 0 or stdout.find("*** PASS") == -1:
         print """TEST-UNEXPECTED-FAIL | %s | test failed (with xpcshell return code: %d), see following log:
   >>>>>>>
   %s
   <<<<<<<""" % (test, proc.returncode, stdout)
         success = False
       else:
         print "TEST-PASS | %s | all tests passed" % test
-      processLeakLog(leakLogFile)
+
+      leakReport = processLeakLog(leakLogFile)
+
+      try:
+        f = open(test + '.log', 'w')
+        f.write(stdout)
+        if leakReport:
+          f.write(leakReport)
+      finally:
+        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
 
 def main():