Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ensure_good_bad_invalid(self):
self.handler.ensure_good_and_bad = True
with self.assertRaisesRegex(MozRegressionError, "expected to be good"):
self.do__bisect(MyBuildData([1, 2, 3, 4, 5]), ["b"])
with self.assertRaisesRegex(MozRegressionError, "expected to be bad"):
self.do__bisect(MyBuildData([1, 2, 3, 4, 5]), ["g", "g"])
def test_handle_mozregression_errors(self):
# Any MozRegressionError subclass is handled with a nice error message
self.app.bisect_nightlies.side_effect = errors.MozRegressionError("my error")
exitcode = self.do_cli([])
self.assertNotEqual(exitcode, 0)
self.assertIn("my error", self.pop_exit_error_msg())
def _find_build_info(self, fetcher_class):
self.started.emit()
fetcher = fetcher_class(self.fetch_config)
try:
self._build_info = fetcher.find_build_info(self.launch_arg)
except MozRegressionError as exc:
self.error.emit(exc)
return
self.step_build_found.emit(self, self._build_info)
self.download_manager.focus_download(self._build_info)
launcher_kwargs["cmdargs"] = []
if options["profile_persistence"] in ("clone-first", "reuse") or options["profile"]:
launcher_kwargs["cmdargs"] += ["--allow-downgrade"]
# Thunderbird will fail to start if passed an URL arg
if options.get("url") and fetch_config.app_name != "thunderbird":
launcher_kwargs["cmdargs"] += [options["url"]]
# Lang only works for firefox-l10n
if options.get("lang"):
if options["application"] == "firefox-l10n":
fetch_config.set_lang(options["lang"])
else:
raise MozRegressionError("Invalid lang argument")
self.worker = self.worker_class(fetch_config, self.test_runner, self.download_manager)
# Move self.bisector in the thread. This will
# allow to the self.bisector slots (connected after the move)
# to be automatically called in the thread.
self.worker.moveToThread(self.thread)
self.worker_created.emit(self.worker)
def _bisect_next(self):
# this is executed in the working thread
if self.test_runner.verdict != "r":
try:
self.mid = self.bisection.search_mid_point(interrupt=self.should_stop.is_set)
except MozRegressionError:
self._finish_on_exception(self.bisection)
return
except StopIteration:
return
# if our last answer was skip, and that the next build
# to use is not chosen yet, ask to choose it.
if (
self._next_build_index is None
and self.test_runner.verdict == "s"
and len(self.bisection.build_range) > 3
):
self.choose_next_build.emit()
return
if self._next_build_index is not None:
"""
Raised when a date can not be parsed from a string.
"""
def __init__(self, date_string, format="Incorrect date format: `%s`"):
MozRegressionError.__init__(self, format % date_string)
class LauncherNotRunnable(MozRegressionError):
"""
Raised when a :class:`mozregression.launchers.Launcher` can not be
run on the system.
"""
class TestCommandError(MozRegressionError):
"""
Raised on a user test command error.
"""
class UnavailableRelease(MozRegressionError):
"""
Raised when firefox release is not available.
"""
def __init__(self, release):
MozRegressionError.__init__(
self, "Unable to find a matching date for" " release %s" % release
)
# so first grab the previous push to get the last known good
# changeset. This needs to be done on the right branch.
try:
jp2 = JsonPushes(branch)
raw = [int(p.push_id) for p in jp2.pushes_within_changes(oldest, youngest)]
data = jp2.pushes(startID=str(min(raw) - 2), endID=str(max(raw)),)
older = data[0].changeset
youngest = data[-1].changeset
# we are ready to bisect further
gr, br = self._reverse_if_find_fix(older, youngest)
result = (branch, gr, br)
except MozRegressionError:
LOG.debug("Got exception", exc_info=True)
raise MozRegressionError(
"Unable to exploit the merge commit. Origin branch is {}, and"
" the commit message for {} was:\n{}".format(
most_recent_push.repo_name, most_recent_push.short_changeset, msg
)
)
LOG.debug("End merge handling")
return result
"""
options = self.options
user_defined_bits = options.bits is not None
options.bits = parse_bits(options.bits or mozinfo.bits)
if options.arch is not None:
if options.app != "gve":
self.logger.warning("--arch ignored for non-GVE app.")
options.arch = None
fetch_config = create_config(
options.app, mozinfo.os, options.bits, mozinfo.processor, options.arch
)
if options.lang:
if options.app != "firefox-l10n":
raise MozRegressionError("--lang is only valid with --app=firefox-l10n")
fetch_config.set_lang(options.lang)
elif options.app == "firefox-l10n":
raise MozRegressionError("app 'firefox-l10n' requires a --lang argument")
if options.build_type:
try:
fetch_config.set_build_type(options.build_type)
except MozRegressionError as msg:
self.logger.warning("%s (Defaulting to %r)" % (msg, fetch_config.build_type))
self.fetch_config = fetch_config
fetch_config.set_repo(options.repo)
fetch_config.set_base_url(options.archive_base_url)
if (
not user_defined_bits
and options.bits == 64
def _get_nightly_repo(self, date):
if date < self.oldest_builds:
raise errors.MozRegressionError(
"firefox-l10n builds not available before {}".format(self.oldest_builds)
)
else:
return "mozilla-central-l10n"