Resolve relative checkout paths before launching Wine tests

This commit is contained in:
Stalkerino
2026-11-23 00:00:56 +01:00
parent aa2988cc55
commit e8ea6447f5
2 changed files with 13 additions and 3 deletions

View File

@ -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)")

View File

@ -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)