1
0
mirror of https://github.com/TheLocehiliosan/yadm synced 2025-06-04 00:23:58 +00:00

Fix testing with WSL.

This commit is contained in:
Christof Warlich 2025-01-07 13:08:25 +01:00
parent 1d69ce370c
commit a2c0d9fb79
2 changed files with 12 additions and 4 deletions

View File

@ -93,7 +93,13 @@ def tst_distro_family(runner):
@pytest.fixture(scope="session")
def tst_sys():
"""Test session's uname value"""
return platform.system()
system = platform.system()
if system == "Linux":
# Additional check for WSL
with open("/proc/version", "r", encoding="utf-8") as f:
if "icrosoft" in f.read():
return "WSL"
return system
@pytest.fixture(scope="session")

View File

@ -24,8 +24,7 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
# Normally /proc/version (set in PROC_VERSION) is inspected to identify
# WSL. During testing, we will override that value.
proc_version = paths.root.join("proc_version")
if proc_value != "missing":
proc_version.write(proc_value)
proc_version.write(proc_value)
script = f"""
YADM_TEST=1 source {paths.pgm}
PROC_VERSION={proc_version}
@ -36,5 +35,8 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
assert run.success
assert run.err == ""
if expected_os == "uname":
expected_os = tst_sys
if tst_sys != "WSL":
expected_os = tst_sys
else:
expected_os = "Linux"
assert run.out.rstrip() == expected_os