зеркало из https://github.com/mozilla/pjs.git
Bug 493792 Refactor runreftest.py for windows mobile changes p=jmaher r=ted
This commit is contained in:
Родитель
6d5bebe34d
Коммит
94cbaedd10
|
@ -44,6 +44,7 @@ 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)
|
||||||
|
|
||||||
from automation import Automation
|
from automation import Automation
|
||||||
from automationutils import *
|
from automationutils import *
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
@ -55,12 +56,15 @@ 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."
|
||||||
|
|
||||||
|
@ -91,6 +95,37 @@ 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):
|
||||||
|
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);
|
||||||
|
@ -102,33 +137,14 @@ class RefTest(object):
|
||||||
self.copyExtraFilesToProfile(options, profileDir)
|
self.copyExtraFilesToProfile(options, profileDir)
|
||||||
|
|
||||||
# browser environment
|
# browser environment
|
||||||
browserEnv = self.automation.environment(xrePath = options.xrePath)
|
browserEnv = self.buildBrowserEnv(options, profileDir)
|
||||||
browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
|
|
||||||
|
|
||||||
# Enable leaks detection to its own log file.
|
self.registerExtension(browserEnv, options, profileDir)
|
||||||
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.getFullPath(manifest)
|
reftestlist = self.getManifestPath(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,
|
||||||
|
@ -138,11 +154,10 @@ 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(leakLogFile, options.leakThreshold)
|
processLeakLog(self.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:
|
||||||
if profileDir:
|
self.cleanup(profileDir)
|
||||||
shutil.rmtree(profileDir)
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def copyExtraFilesToProfile(self, options, profileDir):
|
def copyExtraFilesToProfile(self, options, profileDir):
|
||||||
|
@ -156,40 +171,49 @@ class RefTest(object):
|
||||||
shutil.copy(abspath, dest)
|
shutil.copy(abspath, dest)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
class ReftestOptions(OptionParser):
|
||||||
automation = Automation()
|
|
||||||
parser = OptionParser()
|
|
||||||
reftest = RefTest(automation)
|
|
||||||
|
|
||||||
# we want to pass down everything from automation.__all__
|
def __init__(self, automation):
|
||||||
addCommonOptions(parser,
|
OptionParser.__init__(self)
|
||||||
defaults=dict(zip(automation.__all__,
|
defaults = {}
|
||||||
|
|
||||||
|
# we want to pass down everything from automation.__all__
|
||||||
|
addCommonOptions(self,
|
||||||
|
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")
|
||||||
parser.add_option("--extra-profile-file",
|
self.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")
|
||||||
parser.add_option("--timeout",
|
self.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].")
|
||||||
parser.add_option("--leak-threshold",
|
self.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")
|
||||||
parser.add_option("--utility-path",
|
self.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:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче