1
0
Fork 0
mirror of synced 2025-01-20 19:19:47 -05:00

Fix testing with WSL (#516)

This commit is contained in:
Christof Warlich 2025-01-07 13:08:25 +01:00 committed by Erik Flodin
parent 1d69ce370c
commit 1e5612d707
No known key found for this signature in database
GPG key ID: 420A7C865EE3F85F
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