Skip to content

Commit 0185041

Browse files
committed
add test for bug #15703
1 parent 4ac865d commit 0185041

File tree

1 file changed

+81
-2
lines changed

1 file changed

+81
-2
lines changed

tests/testsuite/bad_config.rs

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
use crate::prelude::*;
44
use cargo_test_support::git::cargo_uses_gitoxide;
55
use cargo_test_support::registry::{self, Package};
6-
use cargo_test_support::str;
7-
use cargo_test_support::{basic_manifest, project, rustc_host};
6+
use cargo_test_support::{basic_manifest, project, rustc_host, str, Project};
87

98
#[cargo_test]
109
fn bad1() {
@@ -3043,3 +3042,83 @@ fn bad_trim_paths() {
30433042
"#]])
30443043
.run();
30453044
}
3045+
3046+
fn bad_target_name_project(target: &str, path: &str, name: &str) -> Project {
3047+
project()
3048+
.file(
3049+
"Cargo.toml",
3050+
&format!(
3051+
r#"
3052+
[package]
3053+
name = "bad-{target}-name"
3054+
edition = "2024"
3055+
3056+
[[{target}]]
3057+
name = "{name}"
3058+
"#
3059+
),
3060+
)
3061+
.file("src/lib.rs", "")
3062+
.file(format!("{path}/{name}"), "")
3063+
.build()
3064+
}
3065+
3066+
#[cargo_test]
3067+
fn bad_bin_name() {
3068+
bad_target_name_project("bin", "src/bin", "bin.rs")
3069+
.cargo("check")
3070+
.with_status(101)
3071+
.with_stderr_data(str![[r#"
3072+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
3073+
3074+
Caused by:
3075+
can't find `bin.rs` bin at `src/bin/bin.rs` or `src/bin/bin.rs/main.rs`. Please specify bin.path if you want to use a non-default path.
3076+
3077+
"#]])
3078+
.run();
3079+
}
3080+
3081+
#[cargo_test]
3082+
fn bad_example_name() {
3083+
bad_target_name_project("example", "examples", "example.rs")
3084+
.cargo("check")
3085+
.with_status(101)
3086+
.with_stderr_data(str![[r#"
3087+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
3088+
3089+
Caused by:
3090+
can't find `example.rs` example at `examples/example.rs` or `examples/example.rs/main.rs`. Please specify example.path if you want to use a non-default path.
3091+
3092+
"#]])
3093+
.run();
3094+
}
3095+
3096+
#[cargo_test]
3097+
fn bad_test_name() {
3098+
bad_target_name_project("test", "tests", "test.rs")
3099+
.cargo("check")
3100+
.with_status(101)
3101+
.with_stderr_data(str![[r#"
3102+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
3103+
3104+
Caused by:
3105+
can't find `test.rs` test at `tests/test.rs` or `tests/test.rs/main.rs`. Please specify test.path if you want to use a non-default path.
3106+
3107+
"#]])
3108+
.run();
3109+
}
3110+
3111+
#[cargo_test]
3112+
fn bad_bench_name() {
3113+
bad_target_name_project("bench", "benches", "bench.rs")
3114+
.cargo("check")
3115+
.with_status(101)
3116+
.with_stderr_data(str![[r#"
3117+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
3118+
3119+
Caused by:
3120+
can't find `bench.rs` bench at `benches/bench.rs` or `benches/bench.rs/main.rs`. Please specify bench.path if you want to use a non-default path.
3121+
3122+
"#]])
3123+
.run();
3124+
}

0 commit comments

Comments
 (0)