Skip to content

Commit 157ed9f

Browse files
committed
Add test for whitespace behavior in env flags.
1 parent 8777a6b commit 157ed9f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/testsuite/rustdocflags.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,27 @@ fn rustdocflags_misspelled() {
9797
.with_stderr_contains("[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?")
9898
.run();
9999
}
100+
101+
#[cargo_test]
102+
fn whitespace() {
103+
// Checks behavior of different whitespace characters.
104+
let p = project().file("src/lib.rs", "").build();
105+
106+
// "too many operands"
107+
p.cargo("doc")
108+
.env("RUSTDOCFLAGS", "--crate-version this has spaces")
109+
.with_stderr_contains("[ERROR] could not document `foo`")
110+
.with_status(101)
111+
.run();
112+
113+
const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
114+
p.cargo("doc")
115+
.env(
116+
"RUSTDOCFLAGS",
117+
format!("--crate-version {}", SPACED_VERSION),
118+
)
119+
.run();
120+
121+
let contents = p.read_file("target/doc/foo/index.html");
122+
assert!(contents.contains(SPACED_VERSION));
123+
}

0 commit comments

Comments
 (0)