Repository navigation
Bound Git subprocesses in architecture checks and source builds #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ def initialize(self, version, build_data): | |
| if not (root / ".git").exists(): | ||
| return | ||
|
|
||
| tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root) | ||
| tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root, timeout=60) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Duplicated 60 s literal instead of a named budget The task asks for the existing 60-second Git budget ( |
||
| self.build_config.set_exclude_all() | ||
| build_data["force_include"].update( | ||
| (name, name) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| """Exercise the documentation check as a contributor/CI subprocess in real Git.""" | ||
| import os | ||
| import runpy | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
| from types import SimpleNamespace | ||
|
|
||
| import pytest | ||
|
|
||
|
|
@@ -99,6 +101,26 @@ def test_missing_base_fails_closed(git_repo): | |
| assert run(git_repo, "not-a-revision").returncode == 1 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("entry", ["architecture", "sdist"]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: One parametrized test covers two unrelated entry points through an if/else Each |
||
| def test_direct_git_timeout(tmp_path, monkeypatch, capsys, entry): | ||
| def stalled_git(argv, *, timeout, **kwargs): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Test replaces subprocess.run, so it never runs a stalled Git shim The acceptance criteria ask for "a stalled local Git shim" that triggers the timeout. This test instead monkeypatches |
||
| assert timeout == 60 | ||
| raise subprocess.TimeoutExpired(argv, timeout) | ||
|
|
||
| monkeypatch.setattr(subprocess, "run", stalled_git) | ||
| if entry == "architecture": | ||
| monkeypatch.setattr(sys, "argv", [str(SCRIPT), "--links-only"]) | ||
| assert runpy.run_path(str(SCRIPT))["main"]() == 1 | ||
| assert "timed out" in capsys.readouterr().err | ||
| else: | ||
| monkeypatch.setitem(sys.modules, "hatchling.builders.hooks.plugin.interface", | ||
| SimpleNamespace(BuildHookInterface=object)) | ||
| hook = runpy.run_path(str(SCRIPT.parents[1] / "hatch_build.py"))["TrackedSdistFiles"] | ||
| (tmp_path / ".git").mkdir() | ||
| with pytest.raises(subprocess.TimeoutExpired): | ||
| hook.initialize(SimpleNamespace(root=tmp_path), "", {}) | ||
|
|
||
|
|
||
| def test_tach_enforces_module_boundaries(tmp_path): | ||
| import shutil | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.