Skip to content

Commit

Permalink
Add test for whitespace behavior in env flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Sep 15, 2020
1 parent 8777a6b commit 157ed9f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testsuite/rustdocflags.rs
Expand Up @@ -97,3 +97,27 @@ fn rustdocflags_misspelled() {
.with_stderr_contains("[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?")
.run();
}

#[cargo_test]
fn whitespace() {
// Checks behavior of different whitespace characters.
let p = project().file("src/lib.rs", "").build();

// "too many operands"
p.cargo("doc")
.env("RUSTDOCFLAGS", "--crate-version this has spaces")
.with_stderr_contains("[ERROR] could not document `foo`")
.with_status(101)
.run();

const SPACED_VERSION: &str = "a\nb\tc\u{00a0}d";
p.cargo("doc")
.env(
"RUSTDOCFLAGS",
format!("--crate-version {}", SPACED_VERSION),
)
.run();

let contents = p.read_file("target/doc/foo/index.html");
assert!(contents.contains(SPACED_VERSION));
}

0 comments on commit 157ed9f

Please sign in to comment.