mirror of
https://github.com/rust-lang/cargo
synced 2024-11-05 18:50:39 +00:00
auto merge of #303 : alexcrichton/cargo/issue-299, r=wycats
Closes #299
This commit is contained in:
commit
8c6e1a3568
2 changed files with 19 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::os::{getcwd};
|
||||
use std::os;
|
||||
use util::{CargoResult, CliError, CliResult, human};
|
||||
|
||||
/// Iteratively search for `file` in `pwd` and its parents, returning
|
||||
|
@ -34,12 +34,12 @@ pub fn find_project_manifest(pwd: &Path, file: &str) -> CargoResult<Path> {
|
|||
pub fn find_root_manifest_for_cwd(manifest_path: Option<String>) -> CliResult<Path> {
|
||||
match manifest_path {
|
||||
Some(path) => Ok(Path::new(path)),
|
||||
None => match find_project_manifest(&getcwd(), "Cargo.toml") {
|
||||
Ok(x) => Ok(x),
|
||||
Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
|
||||
directory or any parent directory", 102))
|
||||
}
|
||||
}
|
||||
None => match find_project_manifest(&os::getcwd(), "Cargo.toml") {
|
||||
Ok(x) => Ok(x),
|
||||
Err(_) => Err(CliError::new("Could not find Cargo.toml in this \
|
||||
directory or any parent directory", 102))
|
||||
}
|
||||
}.map(|path| os::make_absolute(&path))
|
||||
}
|
||||
|
||||
/// Return the path to the `file` in `pwd`, if it exists.
|
||||
|
|
|
@ -24,6 +24,18 @@ test!(cargo_compile_simple {
|
|||
execs().with_stdout("i am foo\n"));
|
||||
})
|
||||
|
||||
test!(cargo_compile_manifest_path {
|
||||
let p = project("foo")
|
||||
.file("Cargo.toml", basic_bin_manifest("foo").as_slice())
|
||||
.file("src/foo.rs", main_file(r#""i am foo""#, []).as_slice());
|
||||
|
||||
assert_that(p.cargo_process("cargo-build")
|
||||
.arg("--manifest-path").arg("foo/Cargo.toml")
|
||||
.cwd(p.root().dir_path()),
|
||||
execs().with_status(0));
|
||||
assert_that(&p.bin("foo"), existing_file());
|
||||
})
|
||||
|
||||
test!(cargo_compile_with_invalid_manifest {
|
||||
let p = project("foo")
|
||||
.file("Cargo.toml", "");
|
||||
|
|
Loading…
Reference in a new issue