Permalink
Browse files

Bug 619204 - Fix disabling of crash reporter, and add logging for cra…

…sh details. r=ctalbert, r=ahal
  • Loading branch information...
1 parent 0ca6115 commit fb1d59df9138817c426f85b4e52f232eb447a506 @whimboo whimboo committed Feb 18, 2014
Showing with 47 additions and 10 deletions.
  1. +41 −8 mozmill/mozmill/__init__.py
  2. +5 −1 mozmill/mozmill/extension/resource/driver/mozmill.js
  3. +1 −1 mozmill/setup.py
@@ -37,6 +37,12 @@
ADDONS = [extension_path, jsbridge.extension_path]
JSBRIDGE_TIMEOUT = 60.
+# Environment variables
+ENVIRONMENT = {
+ # Disable the internal crash reporter
+ 'MOZ_CRASHREPORTER_NO_REPORT': '1',
+}
+
class TestResults(object):
"""Class to accumulate test results and other information."""
@@ -124,6 +130,9 @@ def create(cls, jsbridge_timeout=JSBRIDGE_TIMEOUT,
runner_args = copy.deepcopy(runner_args) or {}
runner_args['profile_args'] = profile_args
+ # update environment variables for API usage
+ os.environ.update(ENVIRONMENT)
+
# create an equipped runner
runner = runner_class.create(**runner_args)
@@ -164,9 +173,13 @@ def __init__(self, runner, jsbridge_port,
# persisted data
self.persisted = {}
- # shutdown parameters
- self.shutdownMode = {}
+ # state parameters
self.endRunnerCalled = False
+ self.running_test = {}
+ self.shutdownMode = {}
+
+ # crash handling parameters
+ self.minidump_save_path = tempfile.gettempdir()
# list of listeners and handlers
self.listeners = []
@@ -189,8 +202,6 @@ def __init__(self, runner, jsbridge_port,
handlers.append(self.results)
self.setup_handlers(handlers)
- # disable the crashreporter
- os.environ['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
### methods for event listeners
@@ -324,7 +335,14 @@ def start_runner(self):
# fetch the application info
if not self.results.appinfo:
- self.results.appinfo = self.get_appinfo()
+ appinfo = self.get_appinfo()
+
+ self.results.appinfo = appinfo
+
+ # We got the application appdata path. Use it for minidump backups.
+ self.minidump_save_path = os.path.join(appinfo['paths']['appdata'],
+ 'Crash Reports',
+ 'pending')
try:
frame = jsbridge.JSObject(self.bridge, js_module_frame)
@@ -425,8 +443,8 @@ def run(self, tests, restart=False):
finally:
# shutdown the test harness cleanly
- self.running_test = None
self.stop()
+ self.running_test = None
def get_appinfo(self):
"""Collect application specific information."""
@@ -470,11 +488,19 @@ def finish(self, fatal=False):
return self.results
+ def check_for_crashes(self):
+ """Check if crashes happened while the test was run"""
+ return self.runner.check_for_crashes(dump_save_path=self.minidump_save_path,
+ test_name=self.running_test.get('path'))
+
def handle_disconnect(self):
"""Handle a JSBridgeDisconnectError for the active process"""
if not self.shutdownMode:
# In case of an unexpected shutdown (e.g. crash) stop the runner
- self.report_disconnect()
+ if self.check_for_crashes():
+ self.report_disconnect("Application crashed")
+ else:
+ self.report_disconnect()
self.stop_runner()
elif self.shutdownMode.get('restart'):
# When the application gets restarted it will get a new process id by
@@ -496,7 +522,7 @@ def handle_disconnect(self):
def report_disconnect(self, message=None):
message = message or 'Disconnect Error: Application unexpectedly closed'
- test = getattr(self, "current_test", {})
+ test = self.running_test
test['passes'] = []
test['fails'] = [{
'exception': {
@@ -541,6 +567,10 @@ def stop(self):
self.start_runner()
self.stop_runner()
+ # Check for remaining crashes
+ if self.check_for_crashes():
+ self.report_disconnect('Application crashed')
+
# stop the back channel and bridge
if self.back_channel:
self.back_channel.close()
@@ -585,6 +615,9 @@ class CLI(mozrunner.CLI):
def __init__(self, args):
+ # Update environmental settings for command line usage
+ os.environ.update(ENVIRONMENT)
+
# event handler plugin names
self.handlers = {}
for handler_class in handlers.handlers():
@@ -126,7 +126,11 @@ function getApplicationDetails() {
platform_buildid: appInfo.platformBuildID,
platform_version: appInfo.platformVersion,
addons: getAddons(),
- startupinfo: getStartupInfo()
+ startupinfo: getStartupInfo(),
+ paths: {
+ appdata: Services.dirsvc.get('UAppData', Ci.nsIFile).path,
+ profile: Services.dirsvc.get('ProfD', Ci.nsIFile).path
+ }
};
return JSON.stringify(details);
View
@@ -11,7 +11,7 @@
deps = ['jsbridge == 3.1-dev',
'ManifestDestiny == 0.5.7',
'mozinfo == 0.7',
- 'mozrunner == 5.34',
+ 'mozrunner == 5.35',
]
# take description from README

0 comments on commit fb1d59d

Please sign in to comment.