test(4/N): restore chromium-installed guard before subprocess spawn#9
Merged
Conversation
_chromium_installed() probed shutil.which("google-chrome"/"chromium-browser"
/"chrome") before scanning the Playwright browser cache. On any machine with
a system Chrome on PATH (CI runners, dev boxes) this short-circuited to True
even when no Playwright/agent-browser build existed, so the fast-fail guard in
_run_browser_command never fired and tests that point detection at an empty
PLAYWRIGHT_BROWSERS_PATH saw a false positive.
Playwright-driven agent-browser does not auto-adopt an arbitrary system Chrome
unless explicitly pointed there via AGENT_BROWSER_EXECUTABLE_PATH (check #1),
so the bare PATH probe was both a false positive and not how the browser is
actually resolved. Removed it; the explicit env override and the Playwright
cache scan remain authoritative.
Fixes 7 tests in tests/tools/test_browser_chromium_check.py.
🔎 Lint report:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
PR 4/N in the test-suite-green effort. Fixes the 7 tests in
tests/tools/test_browser_chromium_check.py, which all share one root cause inthe Chromium-presence detection used by the browser tool's fast-fail guard.
Tests fixed (7)
TestChromiumInstalled::test_false_when_dir_emptyTestChromiumInstalled::test_false_when_only_unrelated_browsersTestChromiumInstalled::test_false_when_path_not_a_dirTestCheckBrowserRequirementsChromium::test_local_mode_missing_chromium_returns_falseTestRunBrowserCommandChromiumGuard::test_local_mode_missing_chromium_returns_error_immediatelyTestRunBrowserCommandChromiumGuard::test_docker_hint_mentions_image_pullTestRunBrowserCommandChromiumGuard::test_non_docker_hint_mentions_agent_browser_installRoot cause
_chromium_installed()probedshutil.which("google-chrome" / "chromium-browser" / "chrome")before scanning the Playwright browser cache. On any machinewith a system Chrome on
PATH(CI runners, dev boxes), that short-circuited toTrueeven when no Playwright / agent-browser build existed.The tests deliberately scope detection to an empty
PLAYWRIGHT_BROWSERS_PATHand patch
os.path.expanduser, expectingFalse— but they don't (andshouldn't have to) neutralize a stray system Chrome on
PATH. So thefast-fail guard in
_run_browser_commandnever fired,subprocess.Popenwasreached, and the
"Should have failed before spawning subprocess"assertiontripped (plus the
is Falseassertions).Sample failure on a runner with Chrome present:
AssertionError: assert 'Chromium' in 'Should have failed before spawning subprocess'.This is environment-fragile behavior: green on a machine without Chrome,
red on one with it — matching the "pre-existing failures on main" pattern.
Fix
Removed the unconditional system-Chrome-on-
PATHprobe. Playwright-drivenagent-browser does not auto-adopt an arbitrary system Chrome unless explicitly
pointed there via
AGENT_BROWSER_EXECUTABLE_PATH(check #1, retained), so thebare
PATHprobe was both a false positive and not how the browser is actuallyresolved at runtime. The explicit env override and the Playwright cache scan
remain authoritative. One commit, one file (
tools/browser_tool.py,+14/-14, mostly the renumbered docstring).
Validation
Remaining on main
~38 pre-existing failures reported on
mainat the start of this effort; thisPR removes 7 of them. (Two unrelated MCP test files —
test_mcp_oauth_metadata.py,test_mcp_tool.py— have import-time collectionerrors that are out of scope here.)
Note
Low Risk
Narrows install detection to match Playwright/agent-browser behavior; may surface “missing Chromium” on hosts that relied on undirected system Chrome without Playwright.
Overview
Tightens when the browser tool considers Chromium “installed” for local mode’s fast-fail guard in
_chromium_installed().Removes the middle check that treated
google-chrome,chromium-browser, orchromeonPATHas enough to pass. That path could report installed on CI/dev boxes with system Chrome but no Playwright/agent-browser build, so_run_browser_commandskipped the early error and hung until timeout.Keeps only
AGENT_BROWSER_EXECUTABLE_PATHand a scan of Playwright cache dirs (chromium-*/chromium_headless_shell-*). System Chrome still counts if pointed at explicitly via the env var. Docstring updated to explain why bare PATH Chrome is excluded.Reviewed by Cursor Bugbot for commit d68ec80. Bugbot is set up for automated code reviews on this repo. Configure here.