Skip to content

Commit 3962982

Browse files
committed
test(profile): Verify spec version parsing
1 parent 4676e87 commit 3962982

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests/testsuite/profile_overrides.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,72 @@ found package specs: bar, bar@0.5.0",
267267
.run();
268268
}
269269

270+
#[cargo_test]
271+
fn profile_override_spec_with_version() {
272+
let p = project()
273+
.file(
274+
"Cargo.toml",
275+
r#"
276+
[package]
277+
name = "foo"
278+
version = "0.0.1"
279+
280+
[dependencies]
281+
bar = { path = "bar" }
282+
283+
[profile.dev.package."bar:0.5.0"]
284+
codegen-units = 2
285+
"#,
286+
)
287+
.file("src/lib.rs", "")
288+
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
289+
.file("bar/src/lib.rs", "")
290+
.build();
291+
292+
p.cargo("check -v")
293+
.with_stderr_contains("[RUNNING] `rustc [..]bar/src/lib.rs [..] -C codegen-units=2 [..]")
294+
.run();
295+
}
296+
297+
#[cargo_test]
298+
fn profile_override_spec_with_partial_version() {
299+
let p = project()
300+
.file(
301+
"Cargo.toml",
302+
r#"
303+
[package]
304+
name = "foo"
305+
version = "0.0.1"
306+
307+
[dependencies]
308+
bar = { path = "bar" }
309+
310+
[profile.dev.package."bar:0.5"]
311+
codegen-units = 2
312+
"#,
313+
)
314+
.file("src/lib.rs", "")
315+
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
316+
.file("bar/src/lib.rs", "")
317+
.build();
318+
319+
p.cargo("check -v")
320+
.with_status(101)
321+
.with_stderr_contains(
322+
"\
323+
error: failed to parse manifest at `[CWD]/Cargo.toml`
324+
325+
Caused by:
326+
TOML parse error at line 9, column 34
327+
|
328+
9 | [profile.dev.package.\"bar:0.5\"]
329+
| ^^^^^^^^^
330+
cannot parse '0.5' as a SemVer version
331+
",
332+
)
333+
.run();
334+
}
335+
270336
#[cargo_test]
271337
fn profile_override_spec() {
272338
let p = project()

0 commit comments

Comments
 (0)