本文整理匯總了Python中runtests.MessageLogger類的典型用法代碼示例。如果您正苦於以下問題:Python MessageLogger類的具體用法?Python MessageLogger怎麽用?Python MessageLogger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了MessageLogger類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run_test_harness
def run_test_harness(options):
if options is None:
raise ValueError(
"Invalid options specified, use --help for a list of valid options")
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
auto.setDeviceManager(options.dm)
runResult = -1
robocop = RobocopTestRunner(auto, options.dm, options)
try:
message_logger.logger = robocop.log
message_logger.buffering = False
robocop.message_logger = message_logger
robocop.log.debug("options=%s" % vars(options))
runResult = robocop.runTests()
except KeyboardInterrupt:
robocop.log.info("runrobocop.py | Received keyboard interrupt")
runResult = -1
except:
traceback.print_exc()
robocop.log.error(
"runrobocop.py | Received unexpected exception while running tests")
runResult = 1
finally:
try:
robocop.cleanup()
except devicemanager.DMError:
# ignore device error while cleaning up
pass
message_logger.finish()
return runResult
示例2: __init__
def __init__(self, marionette_args,
out_of_process=True,
profile_data_dir=None,
locations=os.path.join(here, 'server-locations.txt')):
super(B2GMochitest, self).__init__()
self.marionette_args = marionette_args
self.out_of_process = out_of_process
self.locations_file = locations
self.preferences = []
self.webapps = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.test_script_args = [self.out_of_process]
self.product = 'b2g'
# structured logging
self.message_logger = MessageLogger(logger=log)
if profile_data_dir:
self.preferences = [os.path.join(profile_data_dir, f)
for f in os.listdir(profile_data_dir) if f.startswith('pref')]
self.webapps = [os.path.join(profile_data_dir, f)
for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
# mozinfo is populated by the parent class
if mozinfo.info['debug']:
self.SERVER_STARTUP_TIMEOUT = 180
else:
self.SERVER_STARTUP_TIMEOUT = 90
示例3: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
if options is None:
raise ValueError(
"Invalid options specified, use --help for a list of valid options")
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
auto.setDeviceManager(options.dm)
runResult = -1
robocop = RobocopTestRunner(auto, options.dm, options)
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = options.dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
robocop.log.error("%s is not installed on this device" % expected)
return 1
try:
message_logger.logger = robocop.log
message_logger.buffering = False
robocop.message_logger = message_logger
robocop.log.debug("options=%s" % vars(options))
runResult = robocop.runTests()
except KeyboardInterrupt:
robocop.log.info("runrobocop.py | Received keyboard interrupt")
runResult = -1
except:
traceback.print_exc()
robocop.log.error(
"runrobocop.py | Received unexpected exception while running tests")
runResult = 1
finally:
try:
robocop.cleanup()
except mozdevice.DMError:
# ignore device error while cleaning up
pass
message_logger.finish()
return runResult
示例4: run_test_harness
def run_test_harness(options):
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if options.robocopIni != "":
# turning buffering off as it's not used in robocop
message_logger.buffering = False
# sut may wait up to 300 s for a robocop am process before returning
dm.default_timeout = 320
if isinstance(options.manifestFile, TestManifest):
mp = options.manifestFile
else:
mp = TestManifest(strict=False)
mp.read(options.robocopIni)
filters = []
if options.totalChunks:
filters.append(
chunk_by_slice(options.thisChunk, options.totalChunks))
robocop_tests = mp.active_tests(exists=False, filters=filters, **mozinfo.info)
options.extraPrefs.append('browser.search.suggest.enabled=true')
options.extraPrefs.append('browser.search.suggest.prompted=true')
options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
options.extraPrefs.append('browser.snippets.enabled=false')
options.extraPrefs.append('browser.casting.enabled=true')
options.extraPrefs.append('extensions.autoupdate.enabled=false')
if (options.dm_trans == 'adb' and options.robocopApk):
dm._checkCmd(["install", "-r", options.robocopApk])
if not options.autorun:
# Force a single loop iteration. The iteration will start Fennec and
# the httpd server, but not actually run a test.
options.test_paths = [robocop_tests[0]['name']]
retVal = None
# Filtering tests
active_tests = []
for test in robocop_tests:
if options.test_paths and test['name'] not in options.test_paths:
continue
if 'disabled' in test:
log.info(
'TEST-INFO | skipping %s | %s' %
(test['name'], test['disabled']))
continue
active_tests.append(test)
#.........這裏部分代碼省略.........
示例5: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
message_logger = MessageLogger(logger=None)
process_args = {"messageLogger": message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByDir = False
# roboextender is used by mochitest-chrome tests like test_java_addons.html,
# but not by any plain mochitests
if options.flavor != "chrome":
options.extensionsToExclude.append("[email protected]")
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split("/")[-1]
installed = dm.shellCheckOutput(["pm", "list", "packages", expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split(".")
if productPieces is not None:
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(["getprop", "ro.build.version.sdk"])
log.info("Android sdk version '%s'; will use this to filter manifests" % str(androidVersion))
mozinfo.info["android_version"] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split("/")[-1]
dm.killProcess(procName)
mochitest.mozLogName = "moz.log"
try:
dm.recordLogcat()
retVal = mochitest.runTests(options)
except:
log.error("Automation Error: Exception caught while running tests")
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(options)
except mozdevice.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()
return retVal
示例6: B2GMochitest
class B2GMochitest(MochitestUtilsMixin):
marionette = None
def __init__(self, marionette_args,
out_of_process=True,
profile_data_dir=None,
locations=os.path.join(here, 'server-locations.txt')):
super(B2GMochitest, self).__init__()
self.marionette_args = marionette_args
self.out_of_process = out_of_process
self.locations_file = locations
self.preferences = []
self.webapps = None
self.test_script = os.path.join(here, 'b2g_start_script.js')
self.test_script_args = [self.out_of_process]
self.product = 'b2g'
# structured logging
self.message_logger = MessageLogger(logger=log)
if profile_data_dir:
self.preferences = [os.path.join(profile_data_dir, f)
for f in os.listdir(profile_data_dir) if f.startswith('pref')]
self.webapps = [os.path.join(profile_data_dir, f)
for f in os.listdir(profile_data_dir) if f.startswith('webapp')]
# mozinfo is populated by the parent class
if mozinfo.info['debug']:
self.SERVER_STARTUP_TIMEOUT = 180
else:
self.SERVER_STARTUP_TIMEOUT = 90
def setup_common_options(self, options):
test_url = self.buildTestPath(options)
# For B2G emulators buildURLOptions has been called
# without calling buildTestPath first and that
# causes manifestFile not to be set
if not "manifestFile=tests.json" in self.urlOpts:
self.urlOpts.append("manifestFile=%s" % options.manifestFile)
if len(self.urlOpts) > 0:
test_url += "?" + "&".join(self.urlOpts)
self.test_script_args.append(test_url)
def buildTestPath(self, options, testsToFilter=None):
if options.manifestFile != 'tests.json':
super(B2GMochitest, self).buildTestPath(options, testsToFilter, disabled=False)
return self.buildTestURL(options)
def build_profile(self, options):
# preferences
prefs = {}
for path in self.preferences:
prefs.update(Preferences.read_prefs(path))
for v in options.extraPrefs:
thispref = v.split("=", 1)
if len(thispref) < 2:
print "Error: syntax error in --setpref=" + v
sys.exit(1)
prefs[thispref[0]] = thispref[1]
# interpolate the preferences
interpolation = { "server": "%s:%s" % (options.webServer, options.httpPort),
"OOP": "true" if self.out_of_process else "false" }
prefs = json.loads(json.dumps(prefs) % interpolation)
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
kwargs = {
'addons': self.getExtensionsToInstall(options),
'apps': self.webapps,
'locations': self.locations_file,
'preferences': prefs,
'proxy': {"remote": options.webServer}
}
if options.profile:
self.profile = Profile.clone(options.profile, **kwargs)
else:
self.profile = Profile(**kwargs)
options.profilePath = self.profile.profile
# TODO bug 839108 - mozprofile should probably handle this
manifest = self.addChromeToProfile(options)
self.copyExtraFilesToProfile(options)
return manifest
def run_tests(self, options):
""" Prepare, configure, run tests and cleanup """
manifest = self.build_profile(options)
self.leak_report_file = os.path.join(options.profilePath, "runtests_leaks.log")
# configuring the message logger's buffering
self.message_logger.buffering = options.quiet
if options.debugger or not options.autorun:
timeout = None
else:
#.........這裏部分代碼省略.........
示例7: main
def main():
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
parser = RemoteOptions(auto)
structured.commandline.add_logging_group(parser)
options, args = parser.parse_args()
if (options.dm_trans == "adb"):
if (options.deviceIP):
dm = droid.DroidADB(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidADB(deviceRoot=options.remoteTestRoot)
else:
dm = droid.DroidSUT(options.deviceIP, options.devicePort, deviceRoot=options.remoteTestRoot)
auto.setDeviceManager(dm)
options = parser.verifyRemoteOptions(options, auto)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
if (options == None):
log.error("Invalid options specified, use --help for a list of valid options")
sys.exit(1)
productPieces = options.remoteProductName.split('.')
if (productPieces != None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
options = parser.verifyOptions(options, mochitest)
if (options == None):
sys.exit(1)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent);
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info("Android sdk version '%s'; will use this to filter manifests" % str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if options.robocopIni != "":
# turning buffering off as it's not used in robocop
message_logger.buffering = False
# sut may wait up to 300 s for a robocop am process before returning
dm.default_timeout = 320
mp = manifestparser.TestManifest(strict=False)
# TODO: pull this in dynamically
mp.read(options.robocopIni)
robocop_tests = mp.active_tests(exists=False, **mozinfo.info)
tests = []
my_tests = tests
for test in robocop_tests:
tests.append(test['name'])
if options.totalChunks:
tests_per_chunk = math.ceil(len(tests) / (options.totalChunks * 1.0))
start = int(round((options.thisChunk-1) * tests_per_chunk))
end = int(round(options.thisChunk * tests_per_chunk))
if end > len(tests):
end = len(tests)
my_tests = tests[start:end]
log.info("Running tests %d-%d/%d" % (start+1, end, len(tests)))
dm.removeFile(os.path.join(deviceRoot, "fennec_ids.txt"))
fennec_ids = os.path.abspath(os.path.join(SCRIPT_DIR, "fennec_ids.txt"))
if not os.path.exists(fennec_ids) and options.robocopIds:
fennec_ids = options.robocopIds
dm.pushFile(fennec_ids, os.path.join(deviceRoot, "fennec_ids.txt"))
options.extraPrefs.append('browser.search.suggest.enabled=true')
options.extraPrefs.append('browser.search.suggest.prompted=true')
options.extraPrefs.append('layout.css.devPixelsPerPx=1.0')
options.extraPrefs.append('browser.chrome.dynamictoolbar=false')
options.extraPrefs.append('browser.snippets.enabled=false')
#.........這裏部分代碼省略.........
示例8: run_test_harness
def run_test_harness(options):
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByDir = False
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
if options.dmdPath:
dmdLibrary = "libdmd.so"
dmdPathOnDevice = os.path.join(deviceRoot, dmdLibrary)
dm.removeFile(dmdPathOnDevice)
dm.pushFile(os.path.join(options.dmdPath, dmdLibrary), dmdPathOnDevice)
options.dmdPath = deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
mochitest.nsprLogName = "nspr.log"
try:
dm.recordLogcat()
retVal = mochitest.runTests(options)
except:
log.error("Automation Error: Exception caught while running tests")
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(options)
except devicemanager.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()
return retVal
示例9: run_test_harness
def run_test_harness(parser, options):
parser.validate(options)
message_logger = MessageLogger(logger=None)
process_args = {'messageLogger': message_logger}
auto = RemoteAutomation(None, "fennec", processArgs=process_args)
if options is None:
raise ValueError("Invalid options specified, use --help for a list of valid options")
options.runByManifest = False
# roboextender is used by mochitest-chrome tests like test_java_addons.html,
# but not by any plain mochitests
if options.flavor != 'chrome':
options.extensionsToExclude.append('[email protected]')
dm = options.dm
auto.setDeviceManager(dm)
mochitest = MochiRemote(auto, dm, options)
options.dm = None
log = mochitest.log
message_logger.logger = log
mochitest.message_logger = message_logger
# Check that Firefox is installed
expected = options.app.split('/')[-1]
installed = dm.shellCheckOutput(['pm', 'list', 'packages', expected])
if expected not in installed:
log.error("%s is not installed on this device" % expected)
return 1
productPieces = options.remoteProductName.split('.')
if (productPieces is not None):
auto.setProduct(productPieces[0])
else:
auto.setProduct(options.remoteProductName)
auto.setAppName(options.remoteappname)
logParent = os.path.dirname(options.remoteLogFile)
dm.removeDir(logParent)
dm.mkDir(logParent)
auto.setRemoteLog(options.remoteLogFile)
auto.setServerInfo(options.webServer, options.httpPort, options.sslPort)
if options.log_mach is None:
mochitest.printDeviceInfo()
# Add Android version (SDK level) to mozinfo so that manifest entries
# can be conditional on android_version.
androidVersion = dm.shellCheckOutput(['getprop', 'ro.build.version.sdk'])
log.info(
"Android sdk version '%s'; will use this to filter manifests" %
str(androidVersion))
mozinfo.info['android_version'] = androidVersion
deviceRoot = dm.deviceRoot
options.dumpOutputDirectory = deviceRoot
procName = options.app.split('/')[-1]
dm.killProcess(procName)
if dm.processExist(procName):
log.warning("unable to kill %s before running tests!" % procName)
mochitest.mozLogName = "moz.log"
try:
dm.recordLogcat()
if options.verify:
retVal = mochitest.verifyTests(options)
else:
retVal = mochitest.runTests(options)
except Exception:
log.error("Automation Error: Exception caught while running tests")
traceback.print_exc()
mochitest.stopServers()
try:
mochitest.cleanup(options)
except mozdevice.DMError:
# device error cleaning up... oh well!
pass
retVal = 1
if options.log_mach is None:
mochitest.printDeviceInfo(printLogcat=True)
message_logger.finish()
return retVal