[Bash] Fix Windows cookbook background tasks (#676)
* Fix Windows cookbook background tasks * Add Windows Cookbook reliability follow-ups
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
"""Regression tests for cross-platform helper behavior."""
|
||||
|
||||
from core import platform_compat
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
_MODULE_PATH = Path(__file__).resolve().parents[1] / "core" / "platform_compat.py"
|
||||
_SPEC = importlib.util.spec_from_file_location("platform_compat_under_test", _MODULE_PATH)
|
||||
platform_compat = importlib.util.module_from_spec(_SPEC)
|
||||
assert _SPEC and _SPEC.loader
|
||||
_SPEC.loader.exec_module(platform_compat)
|
||||
|
||||
|
||||
def _reset_bash_cache(monkeypatch):
|
||||
@@ -35,3 +43,19 @@ def test_find_bash_checks_local_app_data_git_install(monkeypatch):
|
||||
monkeypatch.setattr(platform_compat.os.path, "exists", lambda path: path == expected)
|
||||
|
||||
assert platform_compat.find_bash() == expected
|
||||
|
||||
|
||||
def test_find_bash_skips_windows_wsl_stub(monkeypatch):
|
||||
_reset_bash_cache(monkeypatch)
|
||||
monkeypatch.setattr(platform_compat, "IS_WINDOWS", True)
|
||||
|
||||
stub = r"C:\WINDOWS\system32\bash.exe"
|
||||
expected = r"C:\Program Files\Git\bin\bash.exe"
|
||||
monkeypatch.setattr(
|
||||
platform_compat.shutil,
|
||||
"which",
|
||||
lambda name: stub if name == "bash" else None,
|
||||
)
|
||||
monkeypatch.setattr(platform_compat.os.path, "exists", lambda path: path == expected)
|
||||
|
||||
assert platform_compat.find_bash() == expected
|
||||
|
||||
Reference in New Issue
Block a user