test 'harness=false' tests
This commit is contained in:
parent
174a92c39a
commit
33c669679e
11 changed files with 22 additions and 13 deletions
|
|
@ -502,7 +502,7 @@ fn phase_cargo_rustc(args: env::Args) {
|
|||
/// Cargo does not give us this information directly, so we need to check
|
||||
/// various command-line flags.
|
||||
fn is_runnable_crate() -> bool {
|
||||
let is_bin = get_arg_flag_value("--crate-type").as_deref() == Some("bin");
|
||||
let is_bin = get_arg_flag_value("--crate-type").as_deref().unwrap_or("bin") == "bin";
|
||||
let is_test = has_arg_flag("--test");
|
||||
let print = get_arg_flag_value("--print").is_some();
|
||||
(is_bin || is_test) && !print
|
||||
|
|
|
|||
|
|
@ -13,3 +13,7 @@ num_cpus = "1.10.1"
|
|||
|
||||
[lib]
|
||||
test = false # test that this is respected (will show in the output)
|
||||
|
||||
[[test]]
|
||||
name = "no-harness"
|
||||
harness = false
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def cargo_miri(cmd):
|
|||
return args
|
||||
|
||||
def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
|
||||
print("==> Testing `{}` <==".format(name))
|
||||
print("==> Testing {} <==".format(name))
|
||||
## Call `cargo miri`, capture all output
|
||||
p_env = os.environ.copy()
|
||||
p_env.update(env)
|
||||
|
|
@ -50,13 +50,13 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
|
|||
fail("stderr does not match reference")
|
||||
|
||||
def test_cargo_miri_run():
|
||||
test("cargo miri run",
|
||||
test("`cargo miri run`",
|
||||
cargo_miri("run"),
|
||||
"stdout.ref", "stderr.ref",
|
||||
"stdout.ref1", "stderr.ref1",
|
||||
stdin=b'12\n21\n',
|
||||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
|
||||
)
|
||||
test("cargo miri run (with arguments and target)",
|
||||
test("`cargo miri run` (with arguments and target)",
|
||||
cargo_miri("run") + ["--bin", "cargo-miri-test", "--", "hello world", '"hello world"'],
|
||||
"stdout.ref2", "stderr.ref2"
|
||||
)
|
||||
|
|
@ -64,27 +64,27 @@ def test_cargo_miri_run():
|
|||
def test_cargo_miri_test():
|
||||
# rustdoc is not run on foreign targets
|
||||
is_foreign = 'MIRI_TEST_TARGET' in os.environ
|
||||
rustdoc_ref = "test.stderr.ref2" if is_foreign else "test.stderr.ref"
|
||||
rustdoc_ref = "test.stderr.ref2" if is_foreign else "test.stderr.ref1"
|
||||
|
||||
test("cargo miri test",
|
||||
test("`cargo miri test`",
|
||||
cargo_miri("test"),
|
||||
"test.stdout.ref",rustdoc_ref,
|
||||
"test.stdout.ref1",rustdoc_ref,
|
||||
env={'MIRIFLAGS': "-Zmiri-seed=feed"},
|
||||
)
|
||||
test("cargo miri test (with filter)",
|
||||
test("`cargo miri test` (with filter)",
|
||||
cargo_miri("test") + ["--", "--format=pretty", "le1"],
|
||||
"test.stdout.ref2", rustdoc_ref
|
||||
)
|
||||
test("cargo miri test (without isolation)",
|
||||
test("`cargo miri test` (without isolation)",
|
||||
cargo_miri("test") + ["--", "--format=pretty", "num_cpus"],
|
||||
"test.stdout.ref3", rustdoc_ref,
|
||||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
|
||||
)
|
||||
test("cargo miri test (test target)",
|
||||
test("`cargo miri test` (test target)",
|
||||
cargo_miri("test") + ["--test", "test", "--", "--format=pretty"],
|
||||
"test.stdout.ref4", "test.stderr.ref2"
|
||||
)
|
||||
test("cargo miri test (bin target)",
|
||||
test("`cargo miri test` (bin target)",
|
||||
cargo_miri("test") + ["--bin", "cargo-miri-test", "--", "--format=pretty"],
|
||||
"test.stdout.ref5", "test.stderr.ref2"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ fn main() {
|
|||
println!("42");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ running 1 test
|
|||
.
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
|
||||
|
||||
no-harness test
|
||||
|
||||
running 8 tests
|
||||
..i.....
|
||||
|
|
@ -3,6 +3,7 @@ running 0 tests
|
|||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
|
||||
|
||||
no-harness test
|
||||
|
||||
running 1 test
|
||||
test simple1 ... ok
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ running 0 tests
|
|||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
|
||||
|
||||
no-harness test
|
||||
|
||||
running 1 test
|
||||
test num_cpus ... ok
|
||||
|
|
|
|||
3
test-cargo-miri/tests/no-harness.rs
Normal file
3
test-cargo-miri/tests/no-harness.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
println!("no-harness test");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue