Skip to content

Commit 58d0425

Browse files
committed
Fill in more configuration deserialization and manifest deserialization tests
1 parent b8df7aa commit 58d0425

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,108 @@ fn warn_semver_metadata() {
14201420
.run();
14211421
}
14221422

1423+
#[cargo_test]
1424+
fn bad_http_ssl_version() {
1425+
// Invalid type in SslVersionConfig.
1426+
let p = project()
1427+
.file(
1428+
".cargo/config.toml",
1429+
r#"
1430+
[http]
1431+
ssl-version = ["tlsv1.2", "tlsv1.3"]
1432+
"#,
1433+
)
1434+
.file("src/lib.rs", "")
1435+
.build();
1436+
1437+
p.cargo("check")
1438+
.with_status(101)
1439+
.with_stderr(
1440+
"\
1441+
[ERROR] error in [..]/config.toml: could not load config key `http.ssl-version`
1442+
1443+
Caused by:
1444+
invalid type: sequence, expected a string or map
1445+
",
1446+
)
1447+
.run();
1448+
}
1449+
1450+
#[cargo_test]
1451+
fn bad_http_ssl_version_range() {
1452+
// Invalid type in SslVersionConfigRange.
1453+
let p = project()
1454+
.file(
1455+
".cargo/config.toml",
1456+
r#"
1457+
[http]
1458+
ssl-version.min = false
1459+
"#,
1460+
)
1461+
.file("src/lib.rs", "")
1462+
.build();
1463+
1464+
p.cargo("check")
1465+
.with_status(101)
1466+
.with_stderr(
1467+
"\
1468+
[ERROR] data did not match any variant of untagged enum SslVersionConfig
1469+
",
1470+
)
1471+
.run();
1472+
}
1473+
1474+
#[cargo_test]
1475+
fn bad_build_jobs() {
1476+
// Invalid type in JobsConfig.
1477+
let p = project()
1478+
.file(
1479+
".cargo/config.toml",
1480+
r#"
1481+
[build]
1482+
jobs = { default = true }
1483+
"#,
1484+
)
1485+
.file("src/lib.rs", "")
1486+
.build();
1487+
1488+
p.cargo("check")
1489+
.with_status(101)
1490+
.with_stderr(
1491+
"\
1492+
[ERROR] data did not match any variant of untagged enum JobsConfig
1493+
",
1494+
)
1495+
.run();
1496+
}
1497+
1498+
#[cargo_test]
1499+
fn bad_build_target() {
1500+
// Invalid type in BuildTargetConfig.
1501+
let p = project()
1502+
.file(
1503+
".cargo/config.toml",
1504+
r#"
1505+
[build]
1506+
target.'cfg(unix)' = "x86_64"
1507+
"#,
1508+
)
1509+
.file("src/lib.rs", "")
1510+
.build();
1511+
1512+
p.cargo("check")
1513+
.with_status(101)
1514+
.with_stderr(
1515+
"\
1516+
[ERROR] error in [..]/config.toml: could not load config key `build.target`
1517+
1518+
Caused by:
1519+
data did not match any variant of untagged enum BuildTargetConfigInner
1520+
",
1521+
)
1522+
.run();
1523+
}
1524+
14231525
#[cargo_test]
14241526
fn bad_target_cfg() {
14251527
// Invalid type in a StringList.

tests/testsuite/lints.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,38 @@ Caused by:
210210
.run();
211211
}
212212

213+
#[cargo_test]
214+
fn invalid_type_in_lint_value() {
215+
let foo = project()
216+
.file(
217+
"Cargo.toml",
218+
r#"
219+
[package]
220+
name = "foo"
221+
version = "0.0.1"
222+
223+
[workspace.lints.rust]
224+
rust-2018-idioms = -1
225+
"#,
226+
)
227+
.file("src/lib.rs", "")
228+
.build();
229+
230+
foo.cargo("check -Zlints")
231+
.masquerade_as_nightly_cargo(&["lints"])
232+
.with_status(101)
233+
.with_stderr(
234+
"\
235+
error: failed to parse manifest at `[..]/Cargo.toml`
236+
237+
Caused by:
238+
data did not match any variant of untagged enum TomlLint
239+
in `rust.rust-2018-idioms`
240+
",
241+
)
242+
.run();
243+
}
244+
213245
#[cargo_test]
214246
fn fail_on_tool_injection() {
215247
let foo = project()

0 commit comments

Comments
 (0)