Skip to content

Commit 2c6647d

Browse files
committed
test(alias): with malformed config no proper error emitted
This demonstrate the old behaviour that no proper error is emitted if there is a parse error during configuration parsing.
1 parent 7c8a5a6 commit 2c6647d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/testsuite/cargo_alias_config.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@ expected a list, but found a integer for [..]",
2929
.run();
3030
}
3131

32+
#[cargo_test]
33+
fn alias_malformed_config_string() {
34+
let p = project()
35+
.file("Cargo.toml", &basic_bin_manifest("foo"))
36+
.file("src/main.rs", "fn main() {}")
37+
.file(
38+
".cargo/config",
39+
r#"
40+
[alias]
41+
b-cargo-test = `
42+
"#,
43+
)
44+
.build();
45+
46+
p.cargo("b-cargo-test -v")
47+
.with_status(101)
48+
.with_stderr(
49+
"\
50+
[ERROR] no such subcommand: `b-cargo-test`
51+
52+
<tab>View all installed commands with `cargo --list`
53+
",
54+
)
55+
.run();
56+
}
57+
58+
#[cargo_test]
59+
fn alias_malformed_config_list() {
60+
let p = project()
61+
.file("Cargo.toml", &basic_bin_manifest("foo"))
62+
.file("src/main.rs", "fn main() {}")
63+
.file(
64+
".cargo/config",
65+
r#"
66+
[alias]
67+
b-cargo-test = [1, 2]
68+
"#,
69+
)
70+
.build();
71+
72+
p.cargo("b-cargo-test -v")
73+
.with_status(101)
74+
.with_stderr(
75+
"\
76+
[ERROR] no such subcommand: `b-cargo-test`
77+
78+
<tab>View all installed commands with `cargo --list`
79+
",
80+
)
81+
.run();
82+
}
83+
3284
#[cargo_test]
3385
fn alias_config() {
3486
let p = project()

0 commit comments

Comments
 (0)