mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 19:52:45 +00:00
d43ee1dd22
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>
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
extern crate cargo;
|
|
extern crate cargotest;
|
|
extern crate hamcrest;
|
|
|
|
use cargotest::support::{project, execs};
|
|
use hamcrest::assert_that;
|
|
|
|
#[test]
|
|
fn simple() {
|
|
let p = project("foo").build();
|
|
|
|
assert_that(p.cargo("version"),
|
|
execs().with_status(0).with_stdout(&format!("{}\n",
|
|
cargo::version())));
|
|
|
|
assert_that(p.cargo("--version"),
|
|
execs().with_status(0).with_stdout(&format!("{}\n",
|
|
cargo::version())));
|
|
|
|
}
|
|
|
|
|
|
#[test]
|
|
#[cfg_attr(target_os = "windows", ignore)]
|
|
fn version_works_without_rustc() {
|
|
let p = project("foo").build();
|
|
assert_that(p.cargo("version").env("PATH", ""),
|
|
execs().with_status(0));
|
|
}
|
|
|
|
#[test]
|
|
fn version_works_with_bad_config() {
|
|
let p = project("foo")
|
|
.file(".cargo/config", "this is not toml")
|
|
.build();
|
|
assert_that(p.cargo("version"),
|
|
execs().with_status(0));
|
|
}
|
|
|
|
#[test]
|
|
fn version_works_with_bad_target_dir() {
|
|
let p = project("foo")
|
|
.file(".cargo/config", r#"
|
|
[build]
|
|
target-dir = 4
|
|
"#)
|
|
.build();
|
|
assert_that(p.cargo("version"),
|
|
execs().with_status(0));
|
|
}
|