Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ os:
- osx

before_script:
# mac os weirdness (https://github.com/travis-ci/travis-ci/issues/6307)
- rvm get stable
# macOS weirdness (https://github.com/travis-ci/travis-ci/issues/6307)
- if [[ "$TRAVIS_OS_NAME" == osx ]]; then rvm get stable; fi
# Compute the rust version we use. We do not use "language: rust" to have more control here.
- |
if [ "$TRAVIS_EVENT_TYPE" = cron ]; then
Expand All @@ -36,35 +36,18 @@ script:
- |
# Test and install plain miri
cargo build --release --all-features &&
#cargo test --release --all-features &&
cargo test --release --all-features &&
cargo install --all-features --force --path .
- |
# get ourselves a MIR-full libstd
xargo/build.sh &&
export MIRI_SYSROOT=~/.xargo/HOST
#- |
# # run all tests with full mir
# cargo test --release --all-features
- |
# run all tests with full mir
cargo test --release --all-features
- |
# Test cargo integration
cd cargo-miri-test &&
# Test `cargo miri`
# We ignore the exit code because we want to see the output even on failure, and
# I found no way to preserve the exit code so that we can test for it later.
# Variables set in this subshell in the parenthesis are not available
# on the outside.
# We assume that if this fails, it'll also print something about the failure on
# stdout/stderr and we'll catch that.
# FIXME: Disabling validation, still investigating whether there is UB here
(cargo miri -q >stdout.real 2>stderr.real -- -Zmiri-disable-validation || true) &&
# Print file names and contents (`cat` would just print contents)
tail -n +0 stdout.real stderr.real &&
# Verify output
diff -u stdout.ref stdout.real &&
diff -u stderr.ref stderr.real &&
# test `cargo miri test`
cargo miri test &&
cd ..
(cd cargo-miri-test && ./run-test.py)

notifications:
email:
Expand Down
43 changes: 43 additions & 0 deletions cargo-miri-test/run-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
'''
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
# FIXME: Disabling validation, still investigating whether there is UB here
p = subprocess.Popen(
["cargo", "miri", "-q", "--", "-Zmiri-disable-validation"],
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)