Skip to content

Commit 33c6696

Browse files
committed
test 'harness=false' tests
1 parent 174a92c commit 33c6696

File tree

11 files changed

+22
-13
lines changed

11 files changed

+22
-13
lines changed

cargo-miri/bin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fn phase_cargo_rustc(args: env::Args) {
502502
/// Cargo does not give us this information directly, so we need to check
503503
/// various command-line flags.
504504
fn is_runnable_crate() -> bool {
505-
let is_bin = get_arg_flag_value("--crate-type").as_deref() == Some("bin");
505+
let is_bin = get_arg_flag_value("--crate-type").as_deref().unwrap_or("bin") == "bin";
506506
let is_test = has_arg_flag("--test");
507507
let print = get_arg_flag_value("--print").is_some();
508508
(is_bin || is_test) && !print

test-cargo-miri/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ num_cpus = "1.10.1"
1313

1414
[lib]
1515
test = false # test that this is respected (will show in the output)
16+
17+
[[test]]
18+
name = "no-harness"
19+
harness = false

test-cargo-miri/run-test.py

Lines changed: 11 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)
@@ -50,41 +50,41 @@ def test(name, cmd, stdout_ref, stderr_ref, stdin=b'', env={}):
5050
fail("stderr does not match reference")
5151

5252
def test_cargo_miri_run():
53-
test("cargo miri run",
53+
test("`cargo miri run`",
5454
cargo_miri("run"),
55-
"stdout.ref", "stderr.ref",
55+
"stdout.ref1", "stderr.ref1",
5656
stdin=b'12\n21\n',
5757
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
5858
)
59-
test("cargo miri run (with arguments and target)",
59+
test("`cargo miri run` (with arguments and target)",
6060
cargo_miri("run") + ["--bin", "cargo-miri-test", "--", "hello world", '"hello world"'],
6161
"stdout.ref2", "stderr.ref2"
6262
)
6363

6464
def test_cargo_miri_test():
6565
# rustdoc is not run on foreign targets
6666
is_foreign = 'MIRI_TEST_TARGET' in os.environ
67-
rustdoc_ref = "test.stderr.ref2" if is_foreign else "test.stderr.ref"
67+
rustdoc_ref = "test.stderr.ref2" if is_foreign else "test.stderr.ref1"
6868

69-
test("cargo miri test",
69+
test("`cargo miri test`",
7070
cargo_miri("test"),
71-
"test.stdout.ref",rustdoc_ref,
71+
"test.stdout.ref1",rustdoc_ref,
7272
env={'MIRIFLAGS': "-Zmiri-seed=feed"},
7373
)
74-
test("cargo miri test (with filter)",
74+
test("`cargo miri test` (with filter)",
7575
cargo_miri("test") + ["--", "--format=pretty", "le1"],
7676
"test.stdout.ref2", rustdoc_ref
7777
)
78-
test("cargo miri test (without isolation)",
78+
test("`cargo miri test` (without isolation)",
7979
cargo_miri("test") + ["--", "--format=pretty", "num_cpus"],
8080
"test.stdout.ref3", rustdoc_ref,
8181
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
8282
)
83-
test("cargo miri test (test target)",
83+
test("`cargo miri test` (test target)",
8484
cargo_miri("test") + ["--test", "test", "--", "--format=pretty"],
8585
"test.stdout.ref4", "test.stderr.ref2"
8686
)
87-
test("cargo miri test (bin target)",
87+
test("`cargo miri test` (bin target)",
8888
cargo_miri("test") + ["--bin", "cargo-miri-test", "--", "--format=pretty"],
8989
"test.stdout.ref5", "test.stderr.ref2"
9090
)

test-cargo-miri/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fn main() {
2828
println!("42");
2929
}
3030
}
31-
3231
}
3332

3433
#[cfg(test)]
File renamed without changes.
File renamed without changes.
File renamed without changes.

test-cargo-miri/test.stdout.ref renamed to test-cargo-miri/test.stdout.ref1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ running 1 test
33
.
44
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
55

6+
no-harness test
67

78
running 8 tests
89
..i.....

test-cargo-miri/test.stdout.ref2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ running 0 tests
33

44
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
55

6+
no-harness test
67

78
running 1 test
89
test simple1 ... ok

test-cargo-miri/test.stdout.ref3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ running 0 tests
33

44
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out
55

6+
no-harness test
67

78
running 1 test
89
test num_cpus ... ok

0 commit comments

Comments
 (0)