Bug 469518 - Enable Reftest leak log in tinderbox (log); (Av1b) Enable (bare) leak log; r=ted.mielczarek
authorSerge Gautherie <sgautherie.bz@free.fr>
Mon, 09 Mar 2009 14:09:04 +0100
changeset 23709 587ef00fc422a9f1c8f9e20721576d1dc71dceab
parent 23708 f0ad22379ffcf516e07291fff095ffe9905f94b8
child 23710 6ec4b2a3a81f93968cd7b5c8f712424b1be5a347
push id867
push usersgautherie.bz@free.fr
push dateMon, 09 Mar 2009 13:11:28 +0000
reviewersted
bugs469518
milestone1.9.1b4pre
Bug 469518 - Enable Reftest leak log in tinderbox (log); (Av1b) Enable (bare) leak log; r=ted.mielczarek
layout/tools/reftest/runreftest.py
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -35,16 +35,17 @@
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 """
 Runs the reftest test harness.
 """
 
+import logging
 import sys, shutil, os, os.path
 SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
 sys.path.append(SCRIPT_DIRECTORY)
 import automation
 from optparse import OptionParser
 from tempfile import mkdtemp
 
 oldcwd = os.getcwd()
@@ -110,26 +111,49 @@ Are you executing $objdir/_tests/reftest
     browserEnv["NO_EM_RESTART"] = "1"
     browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
     appDir = os.path.dirname(options.app)
     if automation.UNIXISH:
       browserEnv["LD_LIBRARY_PATH"] = appDir
       browserEnv["MOZILLA_FIVE_HOME"] = appDir
       browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"
 
+    # Retrieve the logger where to report the leaks to.
+    log = logging.getLogger()
+
+    # Enable leaks (only) detection to its own log file.
+    leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
+    browserEnv["XPCOM_MEM_LEAK_LOG"] = leakLogFile
+
+    def processLeakLog():
+      "Process the leak log."
+      # For the time being, don't warn (nor "info") if the log file is not there. (Bug 469518)
+      if os.path.exists(leakLogFile):
+        leaks = open(leakLogFile, "r")
+        # For the time being, simply copy the log. (Bug 469518)
+        log.info(leaks.read().rstrip())
+        leaks.close()
+
     # run once with -silent to let the extension manager do its thing
     # and then exit the app
+    log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
     (status, start) = automation.runApp(None, browserEnv, options.app,
                                         profileDir,
                                         extraArgs = ["-silent"])
+    # We don't care to call |processLeakLog()| for this step.
+    log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
+
     # then again to actually run reftest
+    log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
     reftestlist = getFullPath(args[0])
     (status, start) = automation.runApp(None, browserEnv, options.app,
                                         profileDir,
                                         extraArgs = ["-reftest", reftestlist])
+    processLeakLog()
+    log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
   finally:
     if profileDir is not None:
       shutil.rmtree(profileDir)
   sys.exit(status)
 
 def copyExtraFilesToProfile(options, profileDir):
   "Copy extra files or dirs specified on the command line to the testing profile."
   for f in options.extraProfileFiles: