diff --git a/test-cargo-miri/run-test.py b/test-cargo-miri/run-test.py index 42745535e0ef..c7ab8f14df88 100755 --- a/test-cargo-miri/run-test.py +++ b/test-cargo-miri/run-test.py @@ -7,11 +7,11 @@ and the working directory to contain the cargo-miri-test project. 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_test(): - print("==> Testing `cargo miri test` <==") - subprocess.check_call(["cargo", "miri", "test"]) +def test_cargo_miri_run(): + test("cargo miri run", ["cargo", "miri", "run", "-q"], "stout.ref", "stderr.ref") -test_cargo_miri() +def test_cargo_miri_test(): + # FIXME: 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_run() test_cargo_miri_test() sys.exit(0) diff --git a/test-cargo-miri/test.stderr.ref b/test-cargo-miri/test.stderr.ref new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/test-cargo-miri/test.stdout.ref b/test-cargo-miri/test.stdout.ref new file mode 100644 index 000000000000..94fd56b0cd6f --- /dev/null +++ b/test-cargo-miri/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/test-cargo-miri/tests/foo.rs b/test-cargo-miri/tests/foo.rs index fb7fad21c9db..9827ae82d6cf 100644 --- a/test-cargo-miri/tests/foo.rs +++ b/test-cargo-miri/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); +}