3 Test whether cargo-miri works properly.
4 Assumes the `MIRI_SYSROOT` env var to be set appropriately,
5 and the working directory to contain the cargo-miri-test project.
11 print("TEST FAIL: {}".format(msg))
14 def test(name, cmd, stdout_ref, stderr_ref):
15 print("==> Testing `{}` <==".format(name))
16 ## Call `cargo miri`, capture all output
19 stdout=subprocess.PIPE,
20 stderr=subprocess.PIPE
22 (stdout, stderr) = p.communicate()
23 stdout = stdout.decode("UTF-8")
24 stderr = stderr.decode("UTF-8")
26 print("=> captured stdout <=")
28 print("=> captured stderr <=")
32 fail("Non-zero exit status")
33 if stdout != open(stdout_ref).read():
34 fail("stdout does not match reference")
35 if stderr != open(stderr_ref).read():
36 fail("stderr does not match reference")
38 def test_cargo_miri_run():
39 test("cargo miri run", ["cargo", "miri", "run", "-q"], "stdout.ref", "stderr.ref")
40 test("cargo miri run (with arguments)",
41 ["cargo", "miri", "run", "-q", "--", "--", "hello world", '"hello world"'],
42 "stdout.ref", "stderr.ref2"
45 def test_cargo_miri_test():
46 test("cargo miri test", ["cargo", "miri", "test", "-q", "--", "-Zmiri-seed=feed"], "test.stdout.ref", "test.stderr.ref")
47 test("cargo miri test (with filter)",
48 ["cargo", "miri", "test", "-q", "--", "--", "impl"],
49 "test.stdout.ref2", "test.stderr.ref"
53 test_cargo_miri_test()
54 print("TEST SUCCESSFUL!")