Skip to content

Commit

Permalink
Auto merge of #8706 - ehuss:flag-whitespace-test, r=alexcrichton
Browse files Browse the repository at this point in the history
Add test for whitespace behavior in env flags.

This is a regression test to ensure that RUSTFLAGS/RUSTDOCFLAGS are split on just the space (0x20) character, and not any other whitespace. Requested at https://github.com/rust-lang/rust/pull/75539/files#r470923329
  • Loading branch information
bors committed Sep 15, 2020
2 parents 8777a6b + 157ed9f commit e4b65bd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
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 e4b65bd

Please sign in to comment.