From 6a9e94c9fa4e97d379658ba17033a3fbb1b86c9e Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 27 Jun 2026 10:47:31 -0700 Subject: [PATCH] Make release-artifacts dirty assertion track real git state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_release_script_generates_checksummed_artifacts hard-coded `dirty == 1`, which only held while the worktree happened to be dirty. The script derives `dirty` from actual git state and RELEASE_ALLOW_DIRTY is a permission flag, not a forced value — so the test failed the moment the tree was clean (all work committed). Compute the expected dirty flag the same way the script does so the test is deterministic on both clean and dirty trees. Co-Authored-By: Claude Opus 4.8 --- tests/test_packaging.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_packaging.py b/tests/test_packaging.py index a476ccc..21fbf3d 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -66,6 +66,21 @@ class TestArchPackaging(unittest.TestCase): self.assertIn("--cleanbuild", script) +def _git_worktree_dirty() -> int: + """Mirror the dirty computation in release-artifacts.sh so the assertion + holds whether the tree is clean (work committed) or dirty (mid-change).""" + def q(*args: str) -> subprocess.CompletedProcess: + return subprocess.run(["git", *args], cwd=ROOT, + capture_output=True, text=True) + if q("diff", "--quiet").returncode != 0: + return 1 + if q("diff", "--cached", "--quiet").returncode != 0: + return 1 + if q("ls-files", "--others", "--exclude-standard").stdout.strip(): + return 1 + return 0 + + class TestReleaseArtifacts(unittest.TestCase): def test_release_script_generates_checksummed_artifacts(self): with tempfile.TemporaryDirectory() as d: @@ -99,7 +114,7 @@ class TestReleaseArtifacts(unittest.TestCase): data = json.loads(manifest.read_text()) self.assertEqual(data["project"], "enodia-sentinel") self.assertEqual(data["version"], version) - self.assertEqual(data["dirty"], 1) + self.assertEqual(data["dirty"], _git_worktree_dirty()) self.assertIn(archive.name, data["artifacts"]) self.assertIn("SHA256SUMS", data["artifacts"])