mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:08:40 +00:00
Resolve relative checkout paths before launching Wine tests
This commit is contained in:
@ -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)")
|
||||
|
||||
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user