tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 2217a43137a59b7dfd5c7f5de04bfd81eeb14706
parent 95c9158b47a436cbee65eeb253b2f1da8a81da4b
Author: Florian Quèze <florian@queze.net>
Date:   Mon, 15 Dec 2025 17:19:37 +0000

Bug 2000240 - avoid printing 'undefined assertion name' for assertions outsides of test tasks, r=ahal.

Differential Revision: https://phabricator.services.mozilla.com/D272661

Diffstat:
Mtesting/mochitest/runtests.py | 8++++----
Mtesting/modules/StructuredLog.sys.mjs | 5-----
Mtesting/mozbase/mozcrash/mozcrash/mozcrash.py | 3+++
Mtesting/mozbase/mozlog/mozlog/formatters/machformatter.py | 3++-
Mtesting/mozbase/mozlog/mozlog/formatters/tbplformatter.py | 11+++++++----
Mtesting/mozbase/mozlog/mozlog/logtypes.py | 2++
6 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py @@ -208,7 +208,7 @@ class MessageLogger: def _fix_subtest_name(self, message): """Make sure subtest name is a string""" - if "subtest" in message and not isinstance(message["subtest"], str): + if message.get("subtest") is not None: message["subtest"] = str(message["subtest"]) def _fix_test_name(self, message): @@ -4255,9 +4255,8 @@ toolbar#nav-bar { ): key = message["test"].split("/")[-1].strip() if key not in self.harness.expectedError: - self.harness.expectedError[key] = message.get( - "message", message["subtest"] - ).strip() + error_msg = message.get("message") or message.get("subtest") or "" + self.harness.expectedError[key] = error_msg.strip() return message def countline(self, message): @@ -4303,6 +4302,7 @@ toolbar#nav-bar { and self.dump_screen_on_timeout and message["action"] == "test_status" and "expected" in message + and message["subtest"] is not None and "Test timed out" in message["subtest"] ): self.harness.dumpScreen(self.utilityPath) diff --git a/testing/modules/StructuredLog.sys.mjs b/testing/modules/StructuredLog.sys.mjs @@ -40,11 +40,6 @@ export class StructuredLogger { stack = null, extra = null ) { - if (subtest === null || subtest === undefined) { - // Fix for assertions that don't pass in a name - subtest = "undefined assertion name"; - } - var data = { test: this.#testId(test), subtest, diff --git a/testing/mozbase/mozcrash/mozcrash/mozcrash.py b/testing/mozbase/mozcrash/mozcrash/mozcrash.py @@ -465,6 +465,9 @@ class CrashInfo: if os.path.exists(extra) and not self.keep: mozfile.remove(extra) + if signature is None: + signature = "[Unknown]" + return StackInfo( path, signature, diff --git a/testing/mozbase/mozlog/mozlog/formatters/machformatter.py b/testing/mozbase/mozlog/mozlog/formatters/machformatter.py @@ -184,7 +184,8 @@ class MachFormatter(base.BaseFormatter): return color(status) def _format_status(self, test, data): - name = data.get("subtest", test) + subtest = data.get("subtest") + name = subtest if subtest is not None else test rv = "%s %s" % ( self._format_expected( data["status"], diff --git a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py @@ -223,16 +223,19 @@ class TbplFormatter(BaseFormatter): status = data["status"] + subtest = data["subtest"] + subtest_str = (" | %s" % subtest) if subtest else "" + if "expected" in data: if status in data.get("known_intermittent", []): status = "KNOWN-INTERMITTENT-%s" % status else: if not message: message = "- expected %s" % data["expected"] - failure_line = "TEST-UNEXPECTED-%s | %s | %s %s\n" % ( + failure_line = "TEST-UNEXPECTED-%s | %s%s %s\n" % ( status, data["test"], - data["subtest"], + subtest_str, message, ) if data["expected"] != "PASS": @@ -240,10 +243,10 @@ class TbplFormatter(BaseFormatter): return failure_line + info_line return failure_line - return "TEST-%s | %s | %s %s\n" % ( + return "TEST-%s | %s%s %s\n" % ( status, data["test"], - data["subtest"], + subtest_str, message, ) diff --git a/testing/mozbase/mozlog/mozlog/logtypes.py b/testing/mozbase/mozlog/mozlog/logtypes.py @@ -164,6 +164,8 @@ class ContainerType(DataType): class Unicode(DataType): def convert(self, data): + if data is None: + return None if isinstance(data, str): return data if isinstance(data, str):