nits and fix non-deterministic test output
This commit is contained in:
parent
f9bd6b0756
commit
2f6dff6da8
3 changed files with 8 additions and 6 deletions
|
|
@ -38,7 +38,7 @@ enum MiriCommand {
|
|||
}
|
||||
|
||||
/// The information to run a crate with the given environment.
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct CrateRunEnv {
|
||||
/// The command-line arguments.
|
||||
args: Vec<String>,
|
||||
|
|
@ -52,13 +52,13 @@ struct CrateRunEnv {
|
|||
|
||||
impl CrateRunEnv {
|
||||
/// Gather all the information we need.
|
||||
fn collect(args: env::Args) -> Self {
|
||||
fn collect(args: env::Args, capture_stdin: bool) -> Self {
|
||||
let args = args.collect();
|
||||
let env = env::vars_os().collect();
|
||||
let current_dir = env::current_dir().unwrap().into_os_string();
|
||||
|
||||
let mut stdin = Vec::new();
|
||||
if env::var_os("MIRI_CALLED_FROM_RUSTDOC").is_some() {
|
||||
if capture_stdin {
|
||||
std::io::stdin().lock().read_to_end(&mut stdin).expect("cannot read stdin");
|
||||
}
|
||||
|
||||
|
|
@ -669,17 +669,18 @@ fn phase_cargo_rustc(mut args: env::Args) {
|
|||
let runnable_crate = !print && is_runnable_crate();
|
||||
|
||||
if runnable_crate && target_crate {
|
||||
let inside_rustdoc = env::var_os("MIRI_CALLED_FROM_RUSTDOC").is_some();
|
||||
// This is the binary or test crate that we want to interpret under Miri.
|
||||
// But we cannot run it here, as cargo invoked us as a compiler -- our stdin and stdout are not
|
||||
// like we want them.
|
||||
// Instead of compiling, we write JSON into the output file with all the relevant command-line flags
|
||||
// and environment variables; this is used when cargo calls us again in the CARGO_TARGET_RUNNER phase.
|
||||
let env = CrateRunEnv::collect(args);
|
||||
let env = CrateRunEnv::collect(args, inside_rustdoc);
|
||||
|
||||
// Rustdoc expects us to exit with an error code if the test is marked as `compile_fail`,
|
||||
// just creating the JSON file is not enough: we need to detect syntax errors,
|
||||
// so we need to run Miri with `MIRI_BE_RUSTC` for a check-only build.
|
||||
if std::env::var_os("MIRI_CALLED_FROM_RUSTDOC").is_some() {
|
||||
if inside_rustdoc {
|
||||
let mut cmd = miri();
|
||||
|
||||
// Ensure --emit argument for a check-only build is present.
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ def test_cargo_miri_test():
|
|||
|
||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||
os.environ["RUST_TEST_NOCAPTURE"] = "0" # this affects test output, so make sure it is not set
|
||||
os.environ["RUST_TEST_THREADS"] = "1" # avoid non-deterministic output due to concurrent test runs
|
||||
|
||||
target_str = " for target {}".format(os.environ['MIRI_TEST_TARGET']) if 'MIRI_TEST_TARGET' in os.environ else ""
|
||||
print(CGREEN + CBOLD + "## Running `cargo miri` tests{}".format(target_str) + CEND)
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
|
|||
|
||||
|
||||
running 3 tests
|
||||
test src/lib.rs - make_true (line 2) ... ok
|
||||
test src/lib.rs - make_true (line 5) ... ok
|
||||
test src/lib.rs - make_true (line 8) ... ok
|
||||
test src/lib.rs - make_true (line 2) ... ok
|
||||
|
||||
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue