-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #2794 - alexcrichton:rustdocflags, r=brson
Add support for RUSTDOCFLAGS Like with RUSTFLAGS, parse this variable to pass along extra arguments to invocations of `rustdoc`.
- Loading branch information
Showing
4 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
extern crate cargotest; | ||
extern crate hamcrest; | ||
|
||
use cargotest::support::{project, execs}; | ||
use hamcrest::assert_that; | ||
|
||
#[test] | ||
fn parses_env() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
"#) | ||
.file("src/lib.rs", ""); | ||
p.build(); | ||
|
||
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo").arg("-v"), | ||
execs().with_status(0) | ||
.with_stderr_contains("\ | ||
[RUNNING] `rustdoc [..] --cfg=foo[..]` | ||
")); | ||
} | ||
|
||
#[test] | ||
fn parses_config() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
"#) | ||
.file("src/lib.rs", "") | ||
.file(".cargo/config", r#" | ||
[build] | ||
rustdocflags = ["--cfg", "foo"] | ||
"#); | ||
p.build(); | ||
|
||
assert_that(p.cargo("doc").arg("-v"), | ||
execs().with_status(0) | ||
.with_stderr_contains("\ | ||
[RUNNING] `rustdoc [..] --cfg foo[..]` | ||
")); | ||
} | ||
|
||
#[test] | ||
fn bad_flags() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
"#) | ||
.file("src/lib.rs", ""); | ||
p.build(); | ||
|
||
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--bogus"), | ||
execs().with_status(101)); | ||
} | ||
|
||
#[test] | ||
fn rerun() { | ||
let p = project("foo") | ||
.file("Cargo.toml", r#" | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
"#) | ||
.file("src/lib.rs", ""); | ||
p.build(); | ||
|
||
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo"), | ||
execs().with_status(0)); | ||
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo"), | ||
execs().with_status(0).with_stderr("")); | ||
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=bar"), | ||
execs().with_status(0).with_stderr("\ | ||
[DOCUMENTING] foo v0.0.1 ([..]) | ||
")); | ||
} |