mirror of
https://github.com/rust-lang/cargo
synced 2024-09-05 23:55:43 +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>
51 lines
1.6 KiB
Rust
51 lines
1.6 KiB
Rust
extern crate cargotest;
|
|
extern crate hamcrest;
|
|
|
|
use cargotest::support::{project, execs, main_file, basic_bin_manifest};
|
|
use hamcrest::{assert_that};
|
|
|
|
fn verify_project_success_output() -> String {
|
|
r#"{"success":"true"}"#.into()
|
|
}
|
|
|
|
#[test]
|
|
fn cargo_verify_project_path_to_cargo_toml_relative() {
|
|
let p = project("foo")
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
.build();
|
|
|
|
assert_that(p.cargo("verify-project")
|
|
.arg("--manifest-path").arg("foo/Cargo.toml")
|
|
.cwd(p.root().parent().unwrap()),
|
|
execs().with_status(0)
|
|
.with_stdout(verify_project_success_output()));
|
|
}
|
|
|
|
#[test]
|
|
fn cargo_verify_project_path_to_cargo_toml_absolute() {
|
|
let p = project("foo")
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
.build();
|
|
|
|
assert_that(p.cargo("verify-project")
|
|
.arg("--manifest-path").arg(p.root().join("Cargo.toml"))
|
|
.cwd(p.root().parent().unwrap()),
|
|
execs().with_status(0)
|
|
.with_stdout(verify_project_success_output()));
|
|
}
|
|
|
|
#[test]
|
|
fn cargo_verify_project_cwd() {
|
|
let p = project("foo")
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
.build();
|
|
|
|
assert_that(p.cargo("verify-project")
|
|
.cwd(p.root()),
|
|
execs().with_status(0)
|
|
.with_stdout(verify_project_success_output()));
|
|
}
|