Skip to content

Commit

Permalink
Bug 1274395 - Delete pending crash reports before running tests; r=jm…
Browse files Browse the repository at this point in the history
…aher
  • Loading branch information
gbrownmozilla committed May 25, 2016
1 parent e3a3439 commit 035100c
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions layout/tools/reftest/reftestcommandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ def __init__(self, **kwargs):
default=None,
help=argparse.SUPPRESS)

self.add_argument("--cleanup-crashes",
action = "store_true",
dest = "cleanupCrashes",
default = False,
help = "Delete pending crash reports before running tests.")

self.add_argument("tests",
metavar="TEST_PATH",
nargs="*",
Expand Down
3 changes: 3 additions & 0 deletions layout/tools/reftest/runreftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ def runTests(self, tests, options, cmdargs=None):
self.killNamedOrphans('ssltunnel')
self.killNamedOrphans('xpcshell')

if options.cleanupCrashes:
mozcrash.cleanup_pending_crash_reports()

manifests = self.resolver.resolveManifests(options, tests)
if options.filter:
manifests[""] = options.filter
Expand Down
7 changes: 7 additions & 0 deletions testing/mochitest/mochitest_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,13 @@ class MochitestArguments(ArgumentContainer):
"help": "Timeout while waiting to receive a message from the marionette server.",
"suppress": True,
}],
[["--cleanup-crashes"],
{"action": "store_true",
"dest": "cleanupCrashes",
"default": False,
"help": "Delete pending crash reports before running tests.",
"suppress": True,
}],
]

defaults = {
Expand Down
3 changes: 3 additions & 0 deletions testing/mochitest/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,9 @@ def runTests(self, options):
self.killNamedOrphans('ssltunnel')
self.killNamedOrphans('xpcshell')

if options.cleanupCrashes:
mozcrash.cleanup_pending_crash_reports()

# Until we have all green, this only runs on bc*/dt*/mochitest-chrome
# jobs, not jetpack*, a11yr (for perf reasons), or plain

Expand Down
30 changes: 30 additions & 0 deletions testing/mozbase/mozcrash/mozcrash/mozcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'check_for_java_exception',
'kill_and_get_minidump',
'log_crashes',
'cleanup_pending_crash_reports',
]

import glob
Expand Down Expand Up @@ -491,6 +492,35 @@ def kill_and_get_minidump(pid, dump_directory, utility_path=None):
if needs_killing:
kill_pid(pid)

def cleanup_pending_crash_reports():
"""
Delete any pending crash reports.
The presence of pending crash reports may be reported by the browser,
affecting test results; it is best to ensure that these are removed
before starting any browser tests.
Firefox stores pending crash reports in "<UAppData>/Crash Reports".
If the browser is not running, it cannot provide <UAppData>, so this
code tries to anticipate its value.
See dom/system/OSFileConstants.cpp for platform variations of <UAppData>.
"""
if mozinfo.isWin:
location = os.path.expanduser("~\\AppData\\Roaming\\Mozilla\\Firefox\\Crash Reports")
elif mozinfo.isMac:
location = os.path.expanduser("~/Library/Application Support/firefox/Crash Reports")
else:
location = os.path.expanduser("~/.mozilla/firefox/Crash Reports")
logger = get_logger()
if os.path.exists(location):
try:
mozfile.remove(location)
logger.info("Removed pending crash reports at '%s'" % location)
except:
pass


if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
Expand Down
2 changes: 2 additions & 0 deletions testing/mozharness/configs/unittests/linux_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"--log-errorsummary=%(error_summary_file)s",
"--use-test-media-devices",
"--screenshot-on-fail",
"--cleanup-crashes",
],
"run_filename": "runtests.py",
"testsdir": "mochitest"
Expand Down Expand Up @@ -159,6 +160,7 @@
"--symbols-path=%(symbols_path)s",
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--cleanup-crashes",
],
"run_filename": "runreftest.py",
"testsdir": "reftest"
Expand Down
2 changes: 2 additions & 0 deletions testing/mozharness/configs/unittests/mac_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--screenshot-on-fail",
"--cleanup-crashes",
],
"run_filename": "runtests.py",
"testsdir": "mochitest"
Expand Down Expand Up @@ -111,6 +112,7 @@
"--utility-path=tests/bin",
"--extra-profile-file=tests/bin/plugins",
"--symbols-path=%(symbols_path)s"
"--cleanup-crashes",
],
"run_filename": "runreftest.py",
"testsdir": "reftest"
Expand Down
2 changes: 2 additions & 0 deletions testing/mozharness/configs/unittests/win_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--screenshot-on-fail",
"--cleanup-crashes",
],
"run_filename": "runtests.py",
"testsdir": "mochitest"
Expand Down Expand Up @@ -124,6 +125,7 @@
"--symbols-path=%(symbols_path)s",
"--log-raw=%(raw_log_file)s",
"--log-errorsummary=%(error_summary_file)s",
"--cleanup-crashes",
],
"run_filename": "runreftest.py",
"testsdir": "reftest"
Expand Down

0 comments on commit 035100c

Please sign in to comment.