From 157ed9f79a55212ac9c39b0c3aa3534c6411b45e Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 15 Sep 2020 14:22:19 -0700 Subject: [PATCH] Add test for whitespace behavior in env flags. --- tests/testsuite/rustdocflags.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index 5a15c446cad..ebe8b31090c 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -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)); +}