diff options
| author | Stalkerino <33660442+Stalkerino@users.noreply.github.com> | 2026-11-23 00:00:56 +0100 |
|---|---|---|
| committer | Stalkerino <33660442+Stalkerino@users.noreply.github.com> | 2026-11-23 00:00:56 +0100 |
| commit | e8ea6447f54f61d04d99cbb4ec9efc4c1918f81f (patch) | |
| tree | 22f14030f872d5cd9733cdda8ebaa964cfa726d8 | |
| parent | aa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff) | |
Resolve relative checkout paths before launching Wine tests
| -rw-r--r-- | scripts/run_wine_tests.py | 2 | ||||
| -rw-r--r-- | 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: | |||
| 241 | ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) | 241 | ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) |
| 242 | ap.add_argument("--tests", required=True, help="ctest --show-only=json-v1 output from the Windows build") | 242 | ap.add_argument("--tests", required=True, help="ctest --show-only=json-v1 output from the Windows build") |
| 243 | ap.add_argument("--windows-root", required=True, help="the Windows checkout the tests were listed in") | 243 | ap.add_argument("--windows-root", required=True, help="the Windows checkout the tests were listed in") |
| 244 | ap.add_argument("--root", default=ROOT, help="the Linux checkout (default: this repository)") | 244 | ap.add_argument("--root", type=os.path.abspath, default=ROOT, help="the Linux checkout (default: this repository)") |
| 245 | ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"), | 245 | ap.add_argument("--wine", type=wine_command, default=os.environ.get("WINE", "wine"), |
| 246 | help="Wine command (default: $WINE or wine)") | 246 | help="Wine command (default: $WINE or wine)") |
| 247 | ap.add_argument("--require", action="append", default=[], help="a test that must pass (repeatable)") | 247 | 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): | |||
| 389 | def command(self, name): | 389 | def command(self, name): |
| 390 | return [WINDOWS_ROOT + "/artifact/" + name] | 390 | return [WINDOWS_ROOT + "/artifact/" + name] |
| 391 | 391 | ||
| 392 | def run_main(self, entries, *extra, stderr=False): | 392 | def run_main(self, entries, *extra, stderr=False, root=None): |
| 393 | listing = self.list_tests(entries) | 393 | listing = self.list_tests(entries) |
| 394 | argv = ["run_wine_tests.py", "--tests", listing, "--windows-root", WINDOWS_ROOT, | 394 | argv = ["run_wine_tests.py", "--tests", listing, "--windows-root", WINDOWS_ROOT, |
| 395 | "--root", str(self.root), "--wine", sys.executable.replace(os.sep, "/"), *extra] | 395 | "--root", str(self.root if root is None else root), "--wine", sys.executable.replace(os.sep, "/"), *extra] |
| 396 | out, err = io.StringIO(), io.StringIO() | 396 | out, err = io.StringIO(), io.StringIO() |
| 397 | with mock.patch.object(sys, "argv", argv), contextlib.redirect_stdout(out), contextlib.redirect_stderr(err): | 397 | with mock.patch.object(sys, "argv", argv), contextlib.redirect_stdout(out), contextlib.redirect_stderr(err): |
| 398 | code = rwt.main() | 398 | code = rwt.main() |
| @@ -403,6 +403,16 @@ class MainTest(unittest.TestCase): | |||
| 403 | self.assertEqual(code, 0) | 403 | self.assertEqual(code, 0) |
| 404 | self.assertIn("1 passed, 0 failed, 0 skipped under Wine (1 tests)", out) | 404 | self.assertIn("1 passed, 0 failed, 0 skipped under Wine (1 tests)", out) |
| 405 | 405 | ||
| 406 | def test_relative_root_launches_the_artifact_from_its_working_directory(self): | ||
| 407 | (self.artifact / "check_cwd.py").write_text( | ||
| 408 | "from pathlib import Path\nassert Path.cwd() == Path(__file__).resolve().parent\n", | ||
| 409 | encoding="utf-8", newline="\n") | ||
| 410 | entry = ctest_entry("ok", self.command("check_cwd.py")) | ||
| 411 | with contextlib.chdir(self.root): | ||
| 412 | code, out, _ = self.run_main([entry], "--require", "ok", root=".") | ||
| 413 | self.assertEqual(code, 0, out) | ||
| 414 | self.assertIn("[PASS] ok", out) | ||
| 415 | |||
| 406 | def test_a_required_test_that_fails_exits_one(self): | 416 | def test_a_required_test_that_fails_exits_one(self): |
| 407 | code, out, _ = self.run_main([ctest_entry("bad", self.command("bad.py"))], "--require", "bad") | 417 | code, out, _ = self.run_main([ctest_entry("bad", self.command("bad.py"))], "--require", "bad") |
| 408 | self.assertEqual(code, 1) | 418 | self.assertEqual(code, 1) |