Skip to content

Commit 44aec50

Browse files
committed
Add tests for warning on misspelled env vars
1 parent d17ccec commit 44aec50

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

tests/testsuite/rustdocflags.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,13 @@ fn rustdocflags_passed_to_rustdoc_through_cargo_test_only_once() {
8585
.env("RUSTDOCFLAGS", "--markdown-no-toc")
8686
.run();
8787
}
88+
89+
#[test]
90+
fn rustdocflags_misspelled() {
91+
let p = project().file("src/main.rs", "fn main() { }").build();
92+
93+
p.cargo("doc")
94+
.env("RUSTDOC_FLAGS", "foo")
95+
.with_stderr_contains("[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?")
96+
.run();
97+
}

tests/testsuite/rustflags.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,3 +1325,37 @@ fn two_matching_in_config() {
13251325
p1.cargo("run").run();
13261326
p1.cargo("build").with_stderr("[FINISHED] [..]").run();
13271327
}
1328+
1329+
#[test]
1330+
fn env_rustflags_misspelled() {
1331+
let p = project().file("src/main.rs", "fn main() { }").build();
1332+
1333+
for cmd in &["check", "build", "run", "test", "bench"] {
1334+
p.cargo(cmd)
1335+
.env("RUST_FLAGS", "foo")
1336+
.with_stderr_contains("[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?")
1337+
.run();
1338+
}
1339+
}
1340+
1341+
#[test]
1342+
fn env_rustflags_misspelled_build_script() {
1343+
let p = project()
1344+
.file(
1345+
"Cargo.toml",
1346+
r#"
1347+
[package]
1348+
name = "foo"
1349+
version = "0.0.1"
1350+
build = "build.rs"
1351+
"#,
1352+
)
1353+
.file("src/lib.rs", "")
1354+
.file("build.rs", "fn main() { }")
1355+
.build();
1356+
1357+
p.cargo("build")
1358+
.env("RUST_FLAGS", "foo")
1359+
.with_stderr_contains("[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?")
1360+
.run();
1361+
}

0 commit comments

Comments
 (0)