mirror of
https://github.com/rust-lang/cargo
synced 2024-07-16 10:38:14 +00:00
![NODA, Kai](/assets/img/avatar_default.png)
Remove is_build: Cell<bool> from ProjectBuilder and introduce a new type Project. is_build==false <-> ProjectBuilder is_build==true <-> Project Also add #[must_use] to ProjectBuilder to confirm its instances are surely consumed by its build() method to produce Project. The same goes for RepoBuilder. ProjectBuilder::cargo_process() was removed as its design heavily depended on the internal mutability. Signed-off-by: NODA, Kai <nodakai@gmail.com>
89 lines
2.2 KiB
Rust
89 lines
2.2 KiB
Rust
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", "")
|
|
.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"]
|
|
"#)
|
|
.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", "")
|
|
.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", "")
|
|
.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("\
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
"));
|
|
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=bar"),
|
|
execs().with_status(0).with_stderr("\
|
|
[DOCUMENTING] foo v0.0.1 ([..])
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
"));
|
|
}
|