Backed out changeset a6a6824e2a0e

This commit is contained in:
Clint Talbert 2010-03-04 10:02:33 -08:00
Родитель a24a3e1a8b
Коммит fee890c083
1 изменённых файлов: 44 добавлений и 65 удалений

Просмотреть файл

@ -44,8 +44,6 @@ Runs the reftest test harness.
import sys, shutil, os, os.path import sys, shutil, os, os.path
SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0]))) SCRIPT_DIRECTORY = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
sys.path.append(SCRIPT_DIRECTORY) sys.path.append(SCRIPT_DIRECTORY)
os.chdir(SCRIPT_DIRECTORY)
from automation import Automation from automation import Automation
from automationutils import * from automationutils import *
from optparse import OptionParser from optparse import OptionParser
@ -57,15 +55,12 @@ class RefTest(object):
def __init__(self, automation): def __init__(self, automation):
self.automation = automation self.automation = automation
os.chdir(SCRIPT_DIRECTORY)
def getFullPath(self, path): def getFullPath(self, path):
"Get an absolute path relative to self.oldcwd." "Get an absolute path relative to self.oldcwd."
return os.path.normpath(os.path.join(self.oldcwd, os.path.expanduser(path))) return os.path.normpath(os.path.join(self.oldcwd, os.path.expanduser(path)))
def getManifestPath(self, path):
"Get the path of the manifest, and for remote testing this function is subclassed to point to remote manifest"
return self.getFullPath(path)
def createReftestProfile(self, options, profileDir): def createReftestProfile(self, options, profileDir):
"Sets up a profile for reftest." "Sets up a profile for reftest."
@ -96,38 +91,6 @@ class RefTest(object):
extFile.write(reftestExtensionPath) extFile.write(reftestExtensionPath)
extFile.close() extFile.close()
def registerExtension(self, browserEnv, options, profileDir, extraArgs = ['-silent']):
# run once with -silent to let the extension manager do its thing
# and then exit the app
self.automation.log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
# Don't care about this |status|: |runApp()| reporting it should be enough.
status = self.automation.runApp(None, browserEnv, options.app, profileDir,
extraArgs,
utilityPath = options.utilityPath,
xrePath=options.xrePath,
symbolsPath=options.symbolsPath)
# We don't care to call |processLeakLog()| for this step.
self.automation.log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
# Remove the leak detection file so it can't "leak" to the tests run.
# The file is not there if leak logging was not enabled in the application build.
if os.path.exists(self.leakLogFile):
os.remove(self.leakLogFile)
def buildBrowserEnv(self, options, profileDir):
# browser environment
browserEnv = self.automation.environment(xrePath = options.xrePath)
browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
# Enable leaks detection to its own log file.
self.leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
browserEnv["XPCOM_MEM_BLOAT_LOG"] = self.leakLogFile
return browserEnv
def cleanup(self, profileDir):
if profileDir:
shutil.rmtree(profileDir)
def runTests(self, manifest, options): def runTests(self, manifest, options):
debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs, debuggerInfo = getDebuggerInfo(self.oldcwd, options.debugger, options.debuggerArgs,
options.debuggerInteractive); options.debuggerInteractive);
@ -137,12 +100,35 @@ class RefTest(object):
profileDir = mkdtemp() profileDir = mkdtemp()
self.createReftestProfile(options, profileDir) self.createReftestProfile(options, profileDir)
self.copyExtraFilesToProfile(options, profileDir) self.copyExtraFilesToProfile(options, profileDir)
browserEnv = self.buildBrowserEnv(options, profileDir)
self.registerExtension(browserEnv, options, profileDir) # browser environment
browserEnv = self.automation.environment(xrePath = options.xrePath)
browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
# Enable leaks detection to its own log file.
leakLogFile = os.path.join(profileDir, "runreftest_leaks.log")
browserEnv["XPCOM_MEM_BLOAT_LOG"] = leakLogFile
# run once with -silent to let the extension manager do its thing
# and then exit the app
self.automation.log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
# Don't care about this |status|: |runApp()| reporting it should be enough.
status = self.automation.runApp(None, browserEnv, options.app, profileDir,
["-silent"],
utilityPath = options.utilityPath,
xrePath=options.xrePath,
symbolsPath=options.symbolsPath)
# We don't care to call |processLeakLog()| for this step.
self.automation.log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
# Remove the leak detection file so it can't "leak" to the tests run.
# The file is not there if leak logging was not enabled in the application build.
if os.path.exists(leakLogFile):
os.remove(leakLogFile)
# then again to actually run reftest # then again to actually run reftest
self.automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n") self.automation.log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
reftestlist = self.getManifestPath(manifest) reftestlist = self.getFullPath(manifest)
status = self.automation.runApp(None, browserEnv, options.app, profileDir, status = self.automation.runApp(None, browserEnv, options.app, profileDir,
["-reftest", reftestlist], ["-reftest", reftestlist],
utilityPath = options.utilityPath, utilityPath = options.utilityPath,
@ -152,10 +138,11 @@ class RefTest(object):
# give the JS harness 30 seconds to deal # give the JS harness 30 seconds to deal
# with its own timeouts # with its own timeouts
timeout=options.timeout + 30.0) timeout=options.timeout + 30.0)
processLeakLog(self.leakLogFile, options.leakThreshold) processLeakLog(leakLogFile, options.leakThreshold)
self.automation.log.info("\nREFTEST INFO | runreftest.py | Running tests: end.") self.automation.log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
finally: finally:
self.cleanup(profileDir) if profileDir:
shutil.rmtree(profileDir)
return status return status
def copyExtraFilesToProfile(self, options, profileDir): def copyExtraFilesToProfile(self, options, profileDir):
@ -168,50 +155,42 @@ class RefTest(object):
else: else:
shutil.copy(abspath, dest) shutil.copy(abspath, dest)
class ReftestOptions(OptionParser):
def __init__(self, automation): def main():
OptionParser.__init__(self) automation = Automation()
defaults = {} parser = OptionParser()
reftest = RefTest(automation)
# we want to pass down everything from automation.__all__ # we want to pass down everything from automation.__all__
addCommonOptions(self, addCommonOptions(parser,
defaults=dict(zip(automation.__all__, defaults=dict(zip(automation.__all__,
[getattr(automation, x) for x in automation.__all__]))) [getattr(automation, x) for x in automation.__all__])))
automation.addCommonOptions(parser)
automation.addCommonOptions(self) parser.add_option("--appname",
self.add_option("--appname",
action = "store", type = "string", dest = "app", action = "store", type = "string", dest = "app",
default = os.path.join(SCRIPT_DIRECTORY, automation.DEFAULT_APP), default = os.path.join(SCRIPT_DIRECTORY, automation.DEFAULT_APP),
help = "absolute path to application, overriding default") help = "absolute path to application, overriding default")
self.add_option("--extra-profile-file", parser.add_option("--extra-profile-file",
action = "append", dest = "extraProfileFiles", action = "append", dest = "extraProfileFiles",
default = [], default = [],
help = "copy specified files/dirs to testing profile") help = "copy specified files/dirs to testing profile")
self.add_option("--timeout", parser.add_option("--timeout",
action = "store", dest = "timeout", type = "int", action = "store", dest = "timeout", type = "int",
default = 5 * 60, # 5 minutes per bug 479518 default = 5 * 60, # 5 minutes per bug 479518
help = "reftest will timeout in specified number of seconds. [default %default s].") help = "reftest will timeout in specified number of seconds. [default %default s].")
self.add_option("--leak-threshold", parser.add_option("--leak-threshold",
action = "store", type = "int", dest = "leakThreshold", action = "store", type = "int", dest = "leakThreshold",
default = 0, default = 0,
help = "fail if the number of bytes leaked through " help = "fail if the number of bytes leaked through "
"refcounted objects (or bytes in classes with " "refcounted objects (or bytes in classes with "
"MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater " "MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) is greater "
"than the given number") "than the given number")
self.add_option("--utility-path", parser.add_option("--utility-path",
action = "store", type = "string", dest = "utilityPath", action = "store", type = "string", dest = "utilityPath",
default = automation.DIST_BIN, default = automation.DIST_BIN,
help = "absolute path to directory containing utility " help = "absolute path to directory containing utility "
"programs (xpcshell, ssltunnel, certutil)") "programs (xpcshell, ssltunnel, certutil)")
defaults["utilityPath"] = automation.DIST_BIN
self.set_defaults(**defaults)
def main():
automation = Automation()
parser = ReftestOptions(automation)
reftest = RefTest(automation)
options, args = parser.parse_args() options, args = parser.parse_args()
if len(args) != 1: if len(args) != 1:
print >>sys.stderr, "No reftest.list specified." print >>sys.stderr, "No reftest.list specified."