2016-06-20 16:12:28 +00:00
|
|
|
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"),
|
2017-01-18 19:37:52 +00:00
|
|
|
execs().with_status(0).with_stderr("\
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
"));
|
2016-06-20 16:12:28 +00:00
|
|
|
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=bar"),
|
|
|
|
execs().with_status(0).with_stderr("\
|
|
|
|
[DOCUMENTING] foo v0.0.1 ([..])
|
2017-01-18 19:37:52 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-06-20 16:12:28 +00:00
|
|
|
"));
|
|
|
|
}
|