Skip to content

Commit 49cf970

Browse files
committed
test cargo miri test output when testing cargo miri
1 parent 5a17c17 commit 49cf970

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

cargo-miri-test/run-test.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
import sys, subprocess
99

10-
def test_cargo_miri():
11-
print("==> Testing `cargo miri run` <==")
10+
def test(name, cmd, stdout_ref, stderr_ref):
11+
print("==> Testing `{}` <==".format(name))
1212
## Call `cargo miri`, capture all output
1313
p = subprocess.Popen(
14-
["cargo", "miri", "run", "-q"],
14+
cmd,
1515
stdout=subprocess.PIPE,
1616
stderr=subprocess.PIPE
1717
)
@@ -26,17 +26,20 @@ def test_cargo_miri():
2626
# Test for failures
2727
if p.returncode != 0:
2828
sys.exit(1)
29-
if stdout != open('stdout.ref').read():
29+
if stdout != open(stdout_ref).read():
3030
print("stdout does not match reference")
3131
sys.exit(1)
32-
if stderr != open('stderr.ref').read():
32+
if stderr != open(stderr_ref).read():
3333
print("stderr does not match reference")
3434
sys.exit(1)
3535

36+
def test_cargo_miri_run():
37+
test("cargo miri run", ["cargo", "miri", "run", "-q"], "stout.ref", "stderr.ref")
38+
3639
def test_cargo_miri_test():
37-
print("==> Testing `cargo miri test` <==")
38-
subprocess.check_call(["cargo", "miri", "test"])
40+
# validation disabled for now because of https://github.com/rust-lang/rust/issues/54957
41+
test("cargo miri test", ["cargo", "miri", "test", "-q", "--", "-Zmiri-disable-validation"], "stout.ref", "stderr.ref")
3942

40-
test_cargo_miri()
43+
test_cargo_miri_run()
4144
test_cargo_miri_test()
4245
sys.exit(0)

cargo-miri-test/test.stderr.ref

Whitespace-only changes.

cargo-miri-test/test.stdout.ref

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
running 2 tests
3+
test bar ... ok
4+
test baz ... ok
5+
6+
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
7+

cargo-miri-test/tests/foo.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
fn bar() {
33
assert_eq!(4, 4);
44
}
5+
6+
// Having more than 1 test does seem to make a difference
7+
// (i.e., this calls ptr::swap which having just one test does not).
8+
#[test]
9+
fn baz() {
10+
assert_eq!(5, 5);
11+
}

0 commit comments

Comments
 (0)