]>
git.proxmox.com Git - cargo.git/blob - tests/testsuite/rustdocflags.rs
1 //! Tests for setting custom rustdoc flags.
3 use cargo_test_support
::project
;
7 let p
= project().file("src/lib.rs", "").build();
10 .env("RUSTDOCFLAGS", "--cfg=foo")
11 .with_stderr_contains("[RUNNING] `rustdoc [..] --cfg=foo[..]`")
18 .file("src/lib.rs", "")
23 rustdocflags = ["--cfg", "foo"]
29 .with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`")
35 let p
= project().file("src/lib.rs", "").build();
38 .env("RUSTDOCFLAGS", "--bogus")
40 .with_stderr_contains("[..]bogus[..]")
46 let p
= project().file("src/lib.rs", "").build();
48 p
.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo").run();
50 .env("RUSTDOCFLAGS", "--cfg=foo")
51 .with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
54 .env("RUSTDOCFLAGS", "--cfg=bar")
57 [DOCUMENTING] foo v0.0.1 ([..])
58 [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
65 fn rustdocflags_passed_to_rustdoc_through_cargo_test() {
71 //! assert!(cfg!(do_not_choke));
78 .env("RUSTDOCFLAGS", "--cfg do_not_choke")
83 fn rustdocflags_passed_to_rustdoc_through_cargo_test_only_once() {
84 let p
= project().file("src/lib.rs", "").build();
87 .env("RUSTDOCFLAGS", "--markdown-no-toc")
92 fn rustdocflags_misspelled() {
93 let p
= project().file("src/main.rs", "fn main() { }").build();
96 .env("RUSTDOC_FLAGS", "foo")
97 .with_stderr_contains("[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?")
103 // Checks behavior of different whitespace characters.
104 let p
= project().file("src/lib.rs", "").build();
106 // "too many operands"
108 .env("RUSTDOCFLAGS", "--crate-version this has spaces")
109 .with_stderr_contains("[ERROR] could not document `foo`")
113 const SPACED_VERSION
: &str = "a\nb\tc\u{00a0}d";
117 format
!("--crate-version {}", SPACED_VERSION
),
121 let contents
= p
.read_file("target/doc/foo/index.html");
122 assert
!(contents
.contains(SPACED_VERSION
));