Skip to content

Commit 192b535

Browse files
committed
cleaner output for cargo-miri-test harness
1 parent b244a2d commit 192b535

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

test-cargo-miri/run-test.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def cargo_miri(cmd):
2222
return args
2323

2424
def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
25-
print("==> Testing {} <==".format(name))
25+
print("Testing {}...".format(name))
2626
## Call `cargo miri`, capture all output
2727
p_env = os.environ.copy()
2828
p_env.update(env)
@@ -36,18 +36,17 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
3636
(stdout, stderr) = p.communicate(input=stdin)
3737
stdout = stdout.decode("UTF-8")
3838
stderr = stderr.decode("UTF-8")
39+
if p.returncode == 0 and stdout == open(stdout_ref).read() and stderr == open(stderr_ref).read():
40+
# All good!
41+
return
3942
# Show output
40-
print("=> captured stdout <=")
43+
print("--- BEGIN stdout ---")
4144
print(stdout, end="")
42-
print("=> captured stderr <=")
45+
print("--- END stdout ---")
46+
print("--- BEGIN stderr ---")
4347
print(stderr, end="")
44-
# Test for failures
45-
if p.returncode != 0:
46-
fail("Non-zero exit status")
47-
if stdout != open(stdout_ref).read():
48-
fail("stdout does not match reference")
49-
if stderr != open(stderr_ref).read():
50-
fail("stderr does not match reference")
48+
print("--- END stderr ---")
49+
fail("exit code was {}".format(p.returncode))
5150

5251
def test_cargo_miri_run():
5352
test("`cargo miri run` (no isolation)",
@@ -96,7 +95,7 @@ def test_cargo_miri_test():
9695
cargo_miri("test") + ["--bin", "cargo-miri-test", "--", "--format=pretty"],
9796
"test.stdout.ref4", "test.stderr.ref2",
9897
)
99-
test("`cargo miri test` (subcrate)",
98+
test("`cargo miri test` (subcrate, no isolation)",
10099
cargo_miri("test") + ["-p", "subcrate"],
101100
"test.stdout.ref5", "test.stderr.ref2",
102101
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},

0 commit comments

Comments
 (0)