test: enforce bash lru_cache clearance and expose specific skip reasons

Adds a conftest.py pytest fixture to explicitly clear the lru_cache for bash
detection, addressing the monkeypatching hazard in a way that doesn't rely
solely on comments. (Note: CI currently runs python -m unittest, but this
keeps local pytest runners safe.)

Also updates the bash check to run the execution probe directly inside the
cached _check_bash_state, exposing the difference between 'no bash found'
and 'bash present but execution failed' directly to the unittest skip reason.
This commit is contained in:
Gracy769 authored and gaebal-gajae committed 2026-10-12 22:06:08 +00:00
1 parent c31c5e27dd
commit 86cf10a43a
4 files changed
+40 -23

No files matched your search

+3 -3
View File
@@ -5,7 +5,7 @@ import subprocess
import unittest
from pathlib import Path
from tests._bash import get_bash_executable, require_bash
from tests._bash import get_bash_executable, require_bash, bash_skip_reason
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -13,7 +13,7 @@ PRE_PUSH_HOOK = REPO_ROOT / '.github' / 'hooks' / 'pre-push'
class PrePushHookContractTests(unittest.TestCase):
@unittest.skipUnless(require_bash(), 'Requires bash')
@unittest.skipUnless(require_bash(), bash_skip_reason())
def test_skip_escape_hatch_exits_successfully_with_stderr_notice(self) -> None:
bash_cmd = get_bash_executable() or 'bash'
env = os.environ.copy()
@@ -32,7 +32,7 @@ class PrePushHookContractTests(unittest.TestCase):
self.assertIn('SKIP_CLAW_PRE_PUSH_BUILD=1', result.stderr)
self.assertIn('skipping cargo workspace build', result.stderr)
@unittest.skipUnless(require_bash(), 'Requires bash')
@unittest.skipUnless(require_bash(), bash_skip_reason())
def test_default_build_gate_uses_workspace_locked_cargo_build(self) -> None:
hook = PRE_PUSH_HOOK.read_text()