diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 1abcf2b4032..787c64c1c4f 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1755,3 +1755,54 @@ fn json_artifact_includes_executable_for_benchmark() { ) .run(); } + +#[cargo_test] +fn external_bench_warns_wrong_path() { + if !is_nightly() { + return; + } + + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.0.1" + authors = [] + + [[bench]] + name = "external" + "#, + ) + .file( + "src/lib.rs", + r#" + #![feature(test)] + #[cfg(test)] + extern crate test; + + pub fn get_hello() -> &'static str { "Hello" } + "#, + ) + .file( + "./bench/external.rs", + r#" + #![feature(test)] + #[allow(unused_extern_crates)] + extern crate foo; + extern crate test; + + #[bench] + fn external_bench(_b: &mut test::Bencher) {()} + "#, + ) + .build(); + + p.cargo("bench") + .with_status(101) + .with_stderr_contains( + "[..]can't find `[..]` bench at `[..]`, specify [..] if you want to use a non-default path", + ) + .run(); +} diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index cbbcf46cb91..6077c94910c 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1849,7 +1849,7 @@ fn non_existing_example() { [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `hello` example, specify example.path", + can't find `[..]` example at `[..]`, specify [..] if you want to use a non-default path", ) .run(); } @@ -1869,7 +1869,7 @@ fn non_existing_binary() { [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `foo` bin, specify bin.path", + can't find `[..]` bin at `[..]`, specify [..] if you want to use a non-default path", ) .run(); } @@ -4220,7 +4220,7 @@ fn no_bin_in_src_with_lib() { [ERROR] failed to parse manifest at `[..]` Caused by: - can't find `foo` bin, specify bin.path", + can't find `[..]` bin at `[..]`, specify [..] if you want to use a non-default path", ) .run(); } @@ -4397,7 +4397,7 @@ fn same_metadata_different_directory() { } #[cargo_test] -fn building_a_dependent_crate_witout_bin_should_fail() { +fn building_a_dependent_crate_without_bin_should_fail() { Package::new("testless", "0.1.0") .file( "Cargo.toml", @@ -4430,7 +4430,7 @@ fn building_a_dependent_crate_witout_bin_should_fail() { p.cargo("build") .with_status(101) - .with_stderr_contains("[..]can't find `a_bin` bin, specify bin.path") + .with_stderr_contains("[..]can't find `[..]` bin at `[..]`, specify [..] if you want to use a non-default path") .run(); } @@ -5438,3 +5438,27 @@ fn primary_package_env_var() { foo.cargo("test").run(); } + +#[cargo_test] +fn using_bins_instead_of_bin_is_warned_in_err() { + let p = project() + .file( + "Cargo.toml", + r#" + [project] + name = "foo" + version = "0.1.0" + + [[bin]] + name = "a_bin" + "#, + ) + .file("src/lib.rs", "") + .file("bins/a_bin.rs", "fn main { () }") + .build(); + + p.cargo("build") + .with_status(101) + .with_stderr_contains("[..]can't find `[..]` bin at `[..]`, specify [..] if you want to use a non-default path") + .run(); +}