Skip to content

test(4/N): restore chromium-installed guard before subprocess spawn#9

Merged
Bartok9 merged 1 commit into
mainfrom
fix/test-suite-green-4n-browser
May 30, 2026
Merged

test(4/N): restore chromium-installed guard before subprocess spawn#9
Bartok9 merged 1 commit into
mainfrom
fix/test-suite-green-4n-browser

Conversation

@Bartok9

@Bartok9 Bartok9 commented May 30, 2026

Copy link
Copy Markdown
Owner

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 in
the Chromium-presence detection used by the browser tool's fast-fail guard.

Tests fixed (7)

  • TestChromiumInstalled::test_false_when_dir_empty
  • TestChromiumInstalled::test_false_when_only_unrelated_browsers
  • TestChromiumInstalled::test_false_when_path_not_a_dir
  • TestCheckBrowserRequirementsChromium::test_local_mode_missing_chromium_returns_false
  • TestRunBrowserCommandChromiumGuard::test_local_mode_missing_chromium_returns_error_immediately
  • TestRunBrowserCommandChromiumGuard::test_docker_hint_mentions_image_pull
  • TestRunBrowserCommandChromiumGuard::test_non_docker_hint_mentions_agent_browser_install

Root cause

_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), that short-circuited to
True even when no Playwright / agent-browser build existed.

The tests deliberately scope detection to an empty PLAYWRIGHT_BROWSERS_PATH
and patch os.path.expanduser, expecting False — but they don't (and
shouldn't have to) neutralize a stray system Chrome on PATH. So the
fast-fail guard in _run_browser_command never fired, subprocess.Popen was
reached, and the "Should have failed before spawning subprocess" assertion
tripped (plus the is False assertions).

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-PATH probe. Playwright-driven
agent-browser does not auto-adopt an arbitrary system Chrome unless explicitly
pointed there via AGENT_BROWSER_EXECUTABLE_PATH (check #1, retained), so the
bare PATH probe was both a false positive and not how the browser is actually
resolved 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

# WITH google-chrome on PATH (reproduces the CI failure condition)
$ PATH="/tmp/fakebin:$PATH" pytest tests/tools/test_browser_chromium_check.py -n0
  before: 7 failed, 9 passed
  after:  16 passed

# clean environment
$ pytest tests/tools/test_browser_chromium_check.py -n0
  16 passed

# related suites (no regressions)
$ pytest test_browser_chromium_check test_browser_lightpanda \
         test_browser_homebrew_paths test_browser_orphan_reaper -n0
  98 passed

Remaining on main

~38 pre-existing failures reported on main at the start of this effort; this
PR removes 7 of them. (Two unrelated MCP test files —
test_mcp_oauth_metadata.py, test_mcp_tool.py — have import-time collection
errors 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, or chrome on PATH as enough to pass. That path could report installed on CI/dev boxes with system Chrome but no Playwright/agent-browser build, so _run_browser_command skipped the early error and hung until timeout.

Keeps only AGENT_BROWSER_EXECUTABLE_PATH and 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.

_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.
@Bartok9 Bartok9 merged commit eec268e into main May 30, 2026
7 of 8 checks passed
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/test-suite-green-4n-browser vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 7746 on HEAD, 7746 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4076 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant