From fd8fe3502f16f0ac6ce0976b60b975536668cb44 Mon Sep 17 00:00:00 2001 From: Nils Asmussen Date: Thu, 9 Nov 2017 20:42:18 +0100 Subject: [PATCH 1/2] Search for Xargo.toml in parent directories. --- src/xargo.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/xargo.rs b/src/xargo.rs index 168b8c4..06b21bd 100644 --- a/src/xargo.rs +++ b/src/xargo.rs @@ -121,11 +121,10 @@ impl Toml { } pub fn toml(root: &Root) -> Result> { - let p = root.path().join("Xargo.toml"); - - if p.exists() { - util::parse(&p).map(|t| Some(Toml { table: t })) - } else { + if let Some(p) = util::search(root.path(), "Xargo.toml") { + util::parse(&p.join("Xargo.toml")).map(|t| Some(Toml { table: t })) + } + else { Ok(None) } } From 26494e7e7fcf0f349df768d1d53f39c97b5efb67 Mon Sep 17 00:00:00 2001 From: Nils Asmussen Date: Mon, 9 Sep 2019 13:36:35 +0200 Subject: [PATCH 2/2] Added test for Xargo.toml in parent directory. --- tests/smoke.rs | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/smoke.rs b/tests/smoke.rs index 71bc042..9e8b68b 100644 --- a/tests/smoke.rs +++ b/tests/smoke.rs @@ -172,6 +172,10 @@ struct Project { impl Project { fn new(name: &'static str) -> Result { + Self::new_in(std::env::temp_dir(), name) + } + + fn new_in(dir: PathBuf, name: &'static str) -> Result { const JSON: &'static str = r#" { "arch": "arm", @@ -186,7 +190,7 @@ impl Project { } "#; - let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?; + let td = TempDir::new_in(dir, "xargo").chain_err(|| "couldn't create a temporary directory")?; xargo()? .args(&["init", "--lib", "--vcs", "none", "--name", name]) @@ -367,6 +371,32 @@ fn target_dependencies() { run!() } +/// Test building a dependency specified as `target.{}.dependencies` in +/// ../Xargo.toml +#[cfg(feature = "dev")] +#[test] +fn target_dependencies_parentdir() { + fn run() -> Result<()> { + // need this exact target name to get the right gcc flags + const TARGET: &'static str = "thumbv7m-parent-eabi"; + + let td = TempDir::new("xargo").chain_err(|| "couldn't create a temporary directory")?; + let project = Project::new_in(td.path().to_path_buf(), TARGET)?; + write(&td.path().join("Xargo.toml"), false, + r#" +[target.thumbv7m-parent-eabi.dependencies.alloc] +"#, + )?; + project.build(TARGET)?; + assert!(exists("core", TARGET)?); + assert!(exists("alloc", TARGET)?); + + Ok(()) + } + + run!() +} + /// Test building a dependency specified as `dependencies` in Xargo.toml #[cfg(feature = "dev")] #[test]