Bug 475085 - Mochitest leakThreshold should default to 0; (Av1) Set global default to 0 from infinity; r=jwalden+bmo
authorSerge Gautherie <sgautherie.bz@free.fr>
Wed, 25 Feb 2009 17:28:29 +0100
changeset 23426 add530abc9dc34a5754cc693852146ebd7f9d60f
parent 23425 36638fa21466e1f67acf7d263ad5cc0b4cf18d98
child 23427 4071ed82445996684330a03266dd913fabf8d097
push id770
push usersgautherie.bz@free.fr
push dateWed, 25 Feb 2009 16:28:49 +0000
reviewersjwalden
bugs475085
milestone1.9.1b3pre
Bug 475085 - Mochitest leakThreshold should default to 0; (Av1) Set global default to 0 from infinity; r=jwalden+bmo
testing/mochitest/runtests.py.in
--- a/testing/mochitest/runtests.py.in
+++ b/testing/mochitest/runtests.py.in
@@ -171,17 +171,17 @@ class MochitestOptions(optparse.OptionPa
 
     self.add_option("--leak-threshold",
                     action = "store", type = "int",
                     dest = "leakThreshold", metavar = "THRESHOLD",
                     help = "fail if the number of bytes leaked through "
                            "refcounted objects (or bytes in classes with "
                            "MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
                            "than the given number")
-    defaults["leakThreshold"] = INFINITY
+    defaults["leakThreshold"] = 0
 
     self.add_option("--fatal-assertions",
                     action = "store_true", dest = "fatalAssertions",
                     help = "abort testing whenever an assertion is hit "
                            "(requires a debug build to be effective)")
     defaults["fatalAssertions"] = False
 
     # -h, --help are automatically handled by OptionParser
@@ -258,22 +258,16 @@ class MochitestServer:
 #################
 # MAIN FUNCTION #
 #################
 
 def main():
   parser = MochitestOptions()
   options, args = parser.parse_args()
 
-  # If the leak threshold wasn't explicitly set, we override the default of
-  # infinity when the set of tests we're running are known to leak only a
-  # particular amount.  If for some reason you don't want a new leak threshold
-  # enforced, just pass an explicit --leak-threshold=N to prevent the override.
-  maybeForceLeakThreshold(options)
-
   if not os.path.exists(options.app):
     msg = """\
 Error: Path %(app)s doesn't exist.
 Are you executing $objdir/_tests/testing/mochitest/runtests.py?"""
     print msg % {"app": options.app}
     sys.exit(1)
 
   # browser environment
@@ -402,21 +396,19 @@ Are you executing $objdir/_tests/testing
           prefix = "TEST-UNEXPECTED-FAIL"
           leakLog = "TEST-UNEXPECTED-FAIL | runtests-leaks | leaked" \
                     " %d bytes during test execution" % bytesLeaked
         elif bytesLeaked > 0:
           leakLog = "TEST-PASS | runtests-leaks | WARNING leaked" \
                     " %d bytes during test execution" % bytesLeaked
         else:
           leakLog = "TEST-PASS | runtests-leaks | no leaks detected!"
-        # Remind the threshold if it is not 0, which is the goal.
+        # Remind the threshold if it is not 0, which is the default/goal.
         if threshold != 0:
-          leakLog += (threshold == INFINITY) \
-                     and (" (no threshold set)") \
-                     or  (" (threshold set at %d bytes)" % threshold)
+          leakLog += " (threshold set at %d bytes)" % threshold
         # Log the information.
         log.info(leakLog)
       else:
         if numLeaked != 0:
           if abs(numLeaked) > 1:
             instance = "instances"
             rest = " each (%s bytes total)" % matches.group("bytesLeaked")
           else:
@@ -448,36 +440,16 @@ Are you executing $objdir/_tests/testing
   sys.exit(0)
 
 
 
 #######################
 # CONFIGURATION SETUP #
 #######################
 
-def maybeForceLeakThreshold(options):
-  """
-  Modifies an unset leak threshold if it is known that a particular leak
-  threshold can be successfully forced for the particular Mochitest type
-  and platform in use.
-  """
-  if options.leakThreshold == INFINITY:
-    if options.chrome:
-      # We don't leak running the --chrome tests.
-      options.leakThreshold = 0
-    elif options.browserChrome:
-      # We don't leak running the --browser-chrome tests.
-      options.leakThreshold = 0
-    elif options.a11y:
-      # We don't leak running the --a11y tests.
-      options.leakThreshold = 0
-    else:
-      # Normal Mochitests: no leaks.
-      options.leakThreshold = 0
-
 def makeTestConfig(options):
   "Creates a test configuration file for customizing test execution."
   def boolString(b):
     if b:
       return "true"
     return "false"
 
   logFile = options.logFile.replace("\\", "\\\\")