1
0
Fork 0
mirror of synced 2025-01-21 03:29: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") @pytest.fixture(scope="session")
def tst_sys(): def tst_sys():
"""Test session's uname value""" """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") @pytest.fixture(scope="session")

View file

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