From 17c19a09b7f209cd470e6b1eca1dafc4ea4768fe Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 30 Nov 2025 18:11:25 +0100 Subject: [PATCH] build_release: Try to get more information on crashes Currently CI crashes on macOS, but without any useful logs. --- scripts/dev/build_release.py | 102 ++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index cdef25279..ab8844e6a 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -134,7 +134,7 @@ def _smoke_test_run( return subprocess.run(argv, check=True, capture_output=True) -def smoke_test(executable: pathlib.Path, debug: bool) -> None: +def smoke_test(executable: pathlib.Path, debug_build: bool) -> None: """Try starting the given qutebrowser executable.""" stdout_whitelist = [] stderr_whitelist = [ @@ -204,8 +204,15 @@ def smoke_test(executable: pathlib.Path, debug: bool) -> None: r'\(0x80004002\)'), ]) - proc = _smoke_test_run(executable) - if debug: + try: + proc = _smoke_test_run(executable) + except subprocess.CalledProcessError as e: + print(f"Smoke test failed: {e}, running with --debug") + smoke_test_debug(executable, original_stdout=e.stdout.decode('utf-8'), + original_stderr=e.stderr.decode('utf-8')) + return + + if debug_build: print("Skipping output check for debug build") return @@ -214,48 +221,55 @@ def smoke_test(executable: pathlib.Path, debug: bool) -> None: if stdout or stderr: print("Unexpected output, running with --debug") - proc = _smoke_test_run(executable, '--debug') - debug_stdout = proc.stdout.decode('utf-8') - debug_stderr = proc.stderr.decode('utf-8') + smoke_test_debug(executable, original_stdout=stdout, original_stderr=stderr) - lines = [ - "Unexpected output!", + +def smoke_test_debug( + executable: pathlib.Path, *, original_stdout: str, original_stderr: str +) -> None: + """Run smoke test in debug mode to get more output.""" + proc = _smoke_test_run(executable, '--debug') + debug_stdout = proc.stdout.decode('utf-8') + debug_stderr = proc.stderr.decode('utf-8') + + lines = [ + "Unexpected output!", + "", + ] + if original_stdout: + lines += [ + "stdout", + "------", + "", + original_stdout, + "", + ] + if original_stderr: + lines += [ + "stderr", + "------", + "", + original_stderr, + "", + ] + if debug_stdout: + lines += [ + "debug rerun stdout", + "------------------", + "", + debug_stdout, + "", + ] + if debug_stderr: + lines += [ + "debug rerun stderr", + "------------------", + "", + debug_stderr, "", ] - if stdout: - lines += [ - "stdout", - "------", - "", - stdout, - "", - ] - if stderr: - lines += [ - "stderr", - "------", - "", - stderr, - "", - ] - if debug_stdout: - lines += [ - "debug rerun stdout", - "------------------", - "", - debug_stdout, - "", - ] - if debug_stderr: - lines += [ - "debug rerun stderr", - "------------------", - "", - debug_stderr, - "", - ] - raise Exception("\n".join(lines)) # pylint: disable=broad-exception-raised + raise Exception("\n".join(lines)) # pylint: disable=broad-exception-raised def verify_windows_exe(exe_path: pathlib.Path) -> None: @@ -311,7 +325,7 @@ def build_mac( dist_path = pathlib.Path("dist") utils.print_title("Running pre-dmg smoke test") - smoke_test(_mac_bin_path(dist_path), debug=debug) + smoke_test(_mac_bin_path(dist_path), debug_build=debug) if skip_packaging: return [] @@ -334,7 +348,7 @@ def build_mac( subprocess.run(['hdiutil', 'attach', dmg_path, '-mountpoint', tmp_path], check=True) try: - smoke_test(_mac_bin_path(tmp_path), debug=debug) + smoke_test(_mac_bin_path(tmp_path), debug_build=debug) finally: print("Waiting 10s for dmg to be detachable...") time.sleep(10) @@ -393,7 +407,7 @@ def _build_windows_single( verify_windows_exe(exe_path) utils.print_title("Running smoke test") - smoke_test(exe_path, debug=debug) + smoke_test(exe_path, debug_build=debug) if skip_packaging: return []