mirror of https://github.com/rust-lang/cargo
Add a test that reproduces the error of parsing home config twice.
This commit is contained in:
parent
afaffa1cac
commit
fbd43d923c
|
@ -198,6 +198,11 @@ pub fn project(name: &str) -> ProjectBuilder {
|
|||
ProjectBuilder::new(name, paths::root().join(name))
|
||||
}
|
||||
|
||||
// Generates a project layout inside our fake home dir
|
||||
pub fn project_in_home(name: &str) -> ProjectBuilder {
|
||||
ProjectBuilder::new(name, paths::home().join(name))
|
||||
}
|
||||
|
||||
// === Helpers ===
|
||||
|
||||
pub fn main_file(println: &str, deps: &[&str]) -> String {
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::io::Write;
|
|||
use std::fs::{self, File};
|
||||
|
||||
use cargotest::rustc_host;
|
||||
use cargotest::support::{project, execs, paths};
|
||||
use cargotest::support::{project, project_in_home, execs, paths};
|
||||
use hamcrest::assert_that;
|
||||
|
||||
#[test]
|
||||
|
@ -852,3 +852,29 @@ fn build_rustflags_no_recompile() {
|
|||
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
|
||||
execs().with_stdout("").with_status(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_rustflags_with_home_config() {
|
||||
// We need a config file inside the home directory
|
||||
let home = paths::home();
|
||||
let home_config = home.join(".cargo");
|
||||
fs::create_dir(&home_config).unwrap();
|
||||
File::create(&home_config.join("config")).unwrap().write_all(br#"
|
||||
[build]
|
||||
rustflags = ["-Cllvm-args=-x86-asm-syntax=intel"]
|
||||
"#).unwrap();
|
||||
|
||||
// And we need the project to be inside the home directory
|
||||
// so the walking process finds the home project twice.
|
||||
let p = project_in_home("foo")
|
||||
.file("Cargo.toml", r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
"#)
|
||||
.file("src/lib.rs", "");
|
||||
p.build();
|
||||
|
||||
assert_that(p.cargo("build").arg("-v"),
|
||||
execs().with_status(0));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue