A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
web_check: CHROME_PATH overrides the macOS-only Chrome lookup (#289)
alexagofcf8fd3fc7b3
diff --git a/tools/tests/test_web_check.py b/tools/tests/test_web_check.pyindex 3b0f9d683..8a2a45f9e 100644--- a/tools/tests/test_web_check.py+++ b/tools/tests/test_web_check.py@@ -149,3 +149,33 @@ def test_a_failure_line_fails_and_a_silent_running_browser_times_out(capsys):assert "FAIL: GOLDEN FAIL" in capsys.readouterr().outassert run_watch([], exit_code=None) == 1assert "TIMEOUT" in capsys.readouterr().out+++def test_find_chrome_takes_chrome_path_when_set(tmp_path, monkeypatch):+ exe = tmp_path / "chrome.exe"+ exe.write_bytes(b"")+ monkeypatch.setenv("CHROME_PATH", str(exe))+ assert wc.find_chrome() == exe+++def test_find_chrome_refuses_a_chrome_path_that_is_not_a_file(tmp_path, monkeypatch):+ monkeypatch.setenv("CHROME_PATH", str(tmp_path / "missing"))+ try:+ wc.find_chrome()+ except SystemExit as e:+ assert "CHROME_PATH is not a file" in str(e)+ else:+ raise AssertionError("expected SystemExit")+++def test_find_chrome_without_chrome_path_picks_the_newest_revision(tmp_path, monkeypatch):+ # PR #289 review: the override must not change the default lookup, which returns the highest chromium-<rev>.+ monkeypatch.delenv("CHROME_PATH", raising=False)+ monkeypatch.setattr(wc.Path, "home", classmethod(lambda cls: tmp_path))+ found = []+ for rev in ("999", "1223", "1100"):+ exe = tmp_path / "Library" / "Caches" / wc.CHROME_GLOB.replace("chromium-*", f"chromium-{rev}").replace("*", "x")+ exe.parent.mkdir(parents=True, exist_ok=True)+ exe.write_bytes(b"")+ found.append(exe)+ assert wc.find_chrome() == found[1]diff --git a/tools/web_check.py b/tools/web_check.pyindex 7a27ac9b0..0b008e03d 100644--- a/tools/web_check.py+++ b/tools/web_check.py@@ -192,11 +192,20 @@ class ShotCollector:def find_chrome() -> Path:- """The newest Chrome for Testing in the Playwright cache (macOS, arm64 or x64), by numeric revision."""+ """The newest Chrome for Testing in the Playwright cache (macOS, arm64 or x64), by numeric revision.+ CHROME_PATH, when set, overrides the lookup and works on any platform."""+ override = os.environ.get("CHROME_PATH")+ if override:+ path = Path(override)+ if not path.is_file():+ sys.exit(f"CHROME_PATH is not a file: {path}")+ return path+found = list(Path.home().joinpath("Library", "Caches").glob(CHROME_GLOB))if not found:sys.exit("Chrome for Testing not found under ~/Library/Caches/ms-playwright/chromium-<rev>/chrome-mac*"- " (macOS only; install with: npx playwright install chromium)")+ " (macOS only; install with: npx playwright install chromium,"+ " or set CHROME_PATH to a Chrome for Testing executable)")def revision(path: Path) -> int:m = re.search(r"chromium-(\d+)", str(path))