From fd603a7f8f822af288ef3aa1a69226a82edb13d7 Mon Sep 17 00:00:00 2001 From: itzzdev09 Date: Sun, 13 Sep 2026 22:52:06 +0530 Subject: [PATCH] test(build): ignore commented-out uv sync lines in the vertex extra check A commented-out `uv sync ... --extra vertex` would satisfy the assertion even if the real command stopped installing the extra. Only read uncommented lines, and add a test for that case. Co-Authored-By: Claude Opus 5 --- tests/test_optional_deps.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/test_optional_deps.py b/tests/test_optional_deps.py index ba9dca60e..b7c49cf43 100644 --- a/tests/test_optional_deps.py +++ b/tests/test_optional_deps.py @@ -73,6 +73,30 @@ def test_binary_keeps_the_google_auth_modules_vertex_needs() -> None: def test_release_build_installs_the_vertex_extra() -> None: """Keeping google.auth in the bundle only helps if the build installs it.""" workflow = BUILD_RELEASE_WORKFLOW.read_text(encoding="utf-8") - sync_lines = [line.strip() for line in workflow.splitlines() if "uv sync" in line] + # A commented-out command must not satisfy the check: a build that stopped + # installing the extra would otherwise still pass on the comment's text. + sync_lines = [ + line.strip() + for line in workflow.splitlines() + if "uv sync" in line and not line.lstrip().startswith("#") + ] assert sync_lines, "the release workflow no longer runs uv sync" assert all("--extra vertex" in line for line in sync_lines), sync_lines + + +def test_workflow_check_ignores_commented_out_sync_commands(tmp_path: Path) -> None: + """The workflow check must read commands, not comments that mention them.""" + workflow = tmp_path / "build-release.yml" + workflow.write_text( + " run: |\n # uv sync --frozen --extra vertex\n uv sync --frozen\n", + encoding="utf-8", + ) + + sync_lines = [ + line.strip() + for line in workflow.read_text(encoding="utf-8").splitlines() + if "uv sync" in line and not line.lstrip().startswith("#") + ] + + assert sync_lines == ["uv sync --frozen"] + assert not all("--extra vertex" in line for line in sync_lines)