diff --git a/cargo-miri-test/run-test.py b/cargo-miri-test/run-test.py index 42745535e0..3b95488260 100755 --- a/cargo-miri-test/run-test.py +++ b/cargo-miri-test/run-test.py @@ -7,11 +7,11 @@ import sys, subprocess -def test_cargo_miri(): - print("==> Testing `cargo miri run` <==") +def test(name, cmd, stdout_ref, stderr_ref): + print("==> Testing `{}` <==".format(name)) ## Call `cargo miri`, capture all output p = subprocess.Popen( - ["cargo", "miri", "run", "-q"], + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) @@ -26,17 +26,20 @@ def test_cargo_miri(): # Test for failures if p.returncode != 0: sys.exit(1) - if stdout != open('stdout.ref').read(): + if stdout != open(stdout_ref).read(): print("stdout does not match reference") sys.exit(1) - if stderr != open('stderr.ref').read(): + if stderr != open(stderr_ref).read(): print("stderr does not match reference") sys.exit(1) +def test_cargo_miri_run(): + test("cargo miri run", ["cargo", "miri", "run", "-q"], "stout.ref", "stderr.ref") + def test_cargo_miri_test(): - print("==> Testing `cargo miri test` <==") - subprocess.check_call(["cargo", "miri", "test"]) + # validation disabled for now because of https://github.com/rust-lang/rust/issues/54957 + test("cargo miri test", ["cargo", "miri", "test", "-q", "--", "-Zmiri-disable-validation"], "stout.ref", "stderr.ref") -test_cargo_miri() +test_cargo_miri_run() test_cargo_miri_test() sys.exit(0) diff --git a/cargo-miri-test/test.stderr.ref b/cargo-miri-test/test.stderr.ref new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cargo-miri-test/test.stdout.ref b/cargo-miri-test/test.stdout.ref new file mode 100644 index 0000000000..94fd56b0cd --- /dev/null +++ b/cargo-miri-test/test.stdout.ref @@ -0,0 +1,7 @@ + +running 2 tests +test bar ... ok +test baz ... ok + +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + diff --git a/cargo-miri-test/tests/foo.rs b/cargo-miri-test/tests/foo.rs index fb7fad21c9..9827ae82d6 100644 --- a/cargo-miri-test/tests/foo.rs +++ b/cargo-miri-test/tests/foo.rs @@ -2,3 +2,10 @@ fn bar() { assert_eq!(4, 4); } + +// Having more than 1 test does seem to make a difference +// (i.e., this calls ptr::swap which having just one test does not). +#[test] +fn baz() { + assert_eq!(5, 5); +}