mirror of
https://github.com/MadsLorentzen/ai-job-search.git
synced 2026-11-02 13:12:50 +00:00
test(reset): select a working Bash instead of an unusable WSL launcher (#671)
* test(reset): probe Bash variable expansion on Windows Use a bounded variable-expansion probe so a launcher that starts successfully but consumes $x is rejected. Rebase over #676 and keep its upstream-checkout guard alongside Bash discovery. Thanks to MadsLorentzen for diagnosing the launcher expansion failure and verifying the stronger probe. * changelog: place the #671 entry under [Unreleased] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Mads Lorentzen <madslorentzen_17@hotmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
5 files changed
+118
-3
No files matched your search
@@ -0,0 +1,31 @@
|
||||
"""Find a usable Bash for tests that replay the documented reset commands."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
WINDOWS = os.name == "nt"
|
||||
|
||||
|
||||
def find_bash():
|
||||
candidates = [shutil.which("bash")]
|
||||
if WINDOWS:
|
||||
# A Windows PATH may find the WSL launcher even without a usable WSL
|
||||
# installation. Git for Windows also ships Bash beside its cmd/ entry
|
||||
# points, but does not normally add that bin/ directory to PATH.
|
||||
git = shutil.which("git")
|
||||
if git:
|
||||
candidates.append(str(Path(git).resolve().parent.parent / "bin" / "bash.exe"))
|
||||
for candidate in dict.fromkeys(candidates):
|
||||
if not candidate:
|
||||
continue
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[candidate, "-c", 'x=ok; test "$x" = ok'],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=5,
|
||||
)
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
continue
|
||||
if result.returncode == 0:
|
||||
return candidate
|
||||
return None
|
||||
Reference in new issue
Block a user