mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-26 15:36:46 +00:00
Add a lightweight regression for the documented local pre-push build gate so the skip hatch and lockfile-grade cargo build command stay aligned with operator docs. Constraint: Issue #696 scope is limited to pre-push hook contract drift after ROADMAP #694.\nRejected: Reworking the hook harness or roadmap board | unnecessary for the focused drift guard.\nConfidence: high\nScope-risk: narrow\nDirective: Keep the hook docs, skip hatch, and cargo --locked command in sync when changing local push gates.\nTested: bash -n .github/hooks/pre-push; python3 tests/test_pre_push_hook_contract.py -v; git diff --check\nNot-tested: Full cargo workspace build; Rust code was not touched.
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
PRE_PUSH_HOOK = REPO_ROOT / '.github' / 'hooks' / 'pre-push'
|
|
|
|
|
|
class PrePushHookContractTests(unittest.TestCase):
|
|
def test_skip_escape_hatch_exits_successfully_with_stderr_notice(self) -> None:
|
|
env = os.environ.copy()
|
|
env['SKIP_CLAW_PRE_PUSH_BUILD'] = '1'
|
|
|
|
result = subprocess.run(
|
|
['bash', str(PRE_PUSH_HOOK)],
|
|
cwd=REPO_ROOT,
|
|
env=env,
|
|
check=True,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
|
|
self.assertEqual('', result.stdout)
|
|
self.assertIn('SKIP_CLAW_PRE_PUSH_BUILD=1', result.stderr)
|
|
self.assertIn('skipping cargo workspace build', result.stderr)
|
|
|
|
def test_default_build_gate_uses_workspace_locked_cargo_build(self) -> None:
|
|
hook = PRE_PUSH_HOOK.read_text()
|
|
|
|
self.assertIn(
|
|
'cargo build --manifest-path rust/Cargo.toml --workspace --locked',
|
|
hook,
|
|
)
|
|
self.assertIn(
|
|
'build_cmd=(cargo build --manifest-path rust/Cargo.toml --workspace --locked)',
|
|
hook,
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|