From a883c7716972a69b74200d05266f039e4c54f676 Mon Sep 17 00:00:00 2001 From: Jonathan Lee Date: Mon, 22 Apr 2024 14:18:45 -0700 Subject: [PATCH] [wptrunner] Report crash when WebDriver browser is not alive (#45833) This aligns with how the base class `TimedRunner` differentiates `CRASH` from other failure modes [0]. An `InvalidSessionIdException` after a browser death (e.g., [1]) is now coerced to `CRASH`, not the generic `INTERNAL-ERROR` for harness exceptions. Fixes #39617 and https://crbug.com/41485463. [0]: https://github.com/web-platform-tests/wpt/blob/c338ceff/tools/wptrunner/wptrunner/executors/base.py#L216-L231 [1]: https://github.com/web-platform-tests/wpt/blob/c338ceff/tools/wptrunner/wptrunner/executors/base.py#L773 --- tools/wptrunner/wptrunner/executors/base.py | 2 +- tools/wptrunner/wptrunner/executors/executorwebdriver.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/wptrunner/wptrunner/executors/base.py b/tools/wptrunner/wptrunner/executors/base.py index 763b6fcb19fb32..92a782e835c11b 100644 --- a/tools/wptrunner/wptrunner/executors/base.py +++ b/tools/wptrunner/wptrunner/executors/base.py @@ -313,7 +313,7 @@ def run_test(self, test): result = self.do_test(test) except Exception as e: exception_string = traceback.format_exc() - message = f"Exception in TextExecutor.run:\n{exception_string}" + message = f"Exception in TestExecutor.run:\n{exception_string}" self.logger.warning(message) result = self.result_from_exception(test, e, exception_string) diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 3a2f29bdc9df20..69013e5e796979 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -539,7 +539,9 @@ def run_func(self): self.result = True, self.func(self.protocol, self.url, self.timeout) except (error.TimeoutException, error.ScriptTimeoutException): self.result = False, ("EXTERNAL-TIMEOUT", None) - except (socket.timeout, error.UnknownErrorException): + except socket.timeout: + # Checking if the browser is alive below is likely to hang, so mark + # this case as a CRASH unconditionally. self.result = False, ("CRASH", None) except Exception as e: if (isinstance(e, error.WebDriverException) and @@ -548,11 +550,12 @@ def run_func(self): # workaround for https://bugs.chromium.org/p/chromedriver/issues/detail?id=2001 self.result = False, ("EXTERNAL-TIMEOUT", None) else: + status = "INTERNAL-ERROR" if self.protocol.is_alive() else "CRASH" message = str(getattr(e, "message", "")) if message: message += "\n" message += traceback.format_exc() - self.result = False, ("INTERNAL-ERROR", message) + self.result = False, (status, message) finally: self.result_flag.set()