From e8ea6447f54f61d04d99cbb4ec9efc4c1918f81f Mon Sep 17 00:00:00 2001 From: Stalkerino <33660442+Stalkerino@users.noreply.github.com> Date: Mon, 23 Nov 2026 00:00:56 +0100 Subject: [PATCH] Resolve relative checkout paths before launching Wine tests --- scripts/run_wine_tests.py | 2 +- tests/test_run_wine_tests.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py index 3e90e9ab4..182b84360 100644 --- a/scripts/run_wine_tests.py +++ b/scripts/run_wine_tests.py @@ -241,7 +241,7 @@ def main() -> int: ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("--tests", required=True, help="ctest --show-only=json-v1 output from the Windows build") ap.add_argument("--windows-root", required=True, help="the Windows checkout the tests were listed in") - ap.add_argument("--root", default=ROOT, help="the Linux checkout (default: this repository)") + ap.add_argument("--root", type=os.path.abspath, default=ROOT, help="the Linux checkout (default: this repository)") ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"), help="Wine command (default: $WINE or wine)") ap.add_argument("--require", action="append", default=[], help="a test that must pass (repeatable)") diff --git a/tests/test_run_wine_tests.py b/tests/test_run_wine_tests.py index c45b2cc88..6f2b505ff 100644 --- a/tests/test_run_wine_tests.py +++ b/tests/test_run_wine_tests.py @@ -389,10 +389,10 @@ class MainTest(unittest.TestCase): def command(self, name): return [WINDOWS_ROOT + "/artifact/" + name] - def run_main(self, entries, *extra, stderr=False): + def run_main(self, entries, *extra, stderr=False, root=None): listing = self.list_tests(entries) argv = ["run_wine_tests.py", "--tests", listing, "--windows-root", WINDOWS_ROOT, - "--root", str(self.root), "--wine", sys.executable.replace(os.sep, "/"), *extra] + "--root", str(self.root if root is None else root), "--wine", sys.executable.replace(os.sep, "/"), *extra] out, err = io.StringIO(), io.StringIO() with mock.patch.object(sys, "argv", argv), contextlib.redirect_stdout(out), contextlib.redirect_stderr(err): code = rwt.main() @@ -403,6 +403,16 @@ class MainTest(unittest.TestCase): self.assertEqual(code, 0) self.assertIn("1 passed, 0 failed, 0 skipped under Wine (1 tests)", out) + def test_relative_root_launches_the_artifact_from_its_working_directory(self): + (self.artifact / "check_cwd.py").write_text( + "from pathlib import Path\nassert Path.cwd() == Path(__file__).resolve().parent\n", + encoding="utf-8", newline="\n") + entry = ctest_entry("ok", self.command("check_cwd.py")) + with contextlib.chdir(self.root): + code, out, _ = self.run_main([entry], "--require", "ok", root=".") + self.assertEqual(code, 0, out) + self.assertIn("[PASS] ok", out) + def test_a_required_test_that_fails_exits_one(self): code, out, _ = self.run_main([ctest_entry("bad", self.command("bad.py"))], "--require", "bad") self.assertEqual(code, 1)