rust/cargo-miri-test/run-test.py

43 lines
1.2 KiB
Python
Raw Normal View History

2018-10-30 09:07:40 -05:00
#!/usr/bin/env python3
2018-10-30 05:26:53 -05:00
'''
Test whether cargo-miri works properly.
Assumes the `MIRI_SYSROOT` env var to be set appropriately,
and the working directory to contain the cargo-miri-test project.
'''
import sys, subprocess
def test_cargo_miri():
print("==> Testing `cargo miri` <==")
## Call `cargo miri`, capture all output
p = subprocess.Popen(
["cargo", "miri", "-q"],
2018-10-30 05:26:53 -05:00
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
(stdout, stderr) = p.communicate()
stdout = stdout.decode("UTF-8")
stderr = stderr.decode("UTF-8")
# Show output
print("=> captured stdout <=")
print(stdout, end="")
print("=> captured stderr <=")
print(stderr, end="")
# Test for failures
if p.returncode != 0:
sys.exit(1)
if stdout != open('stdout.ref').read():
print("stdout does not match reference")
sys.exit(1)
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"])
test_cargo_miri()
test_cargo_miri_test()
sys.exit(0)