Skip to content

Commit

Permalink
Added test for Xargo.toml in parent directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils-TUD committed Sep 18, 2019
1 parent fd8fe35 commit d0dfcdc
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ struct Project {
}

impl Project {
/// Creates a new project with given name in a temporary directory.
fn new(name: &'static str) -> Result<Self> {
Self::new_in(std::env::temp_dir(), name)
}

/// Creates a new project with given name in a sub directory of `dir`.
fn new_in(dir: PathBuf, name: &'static str) -> Result<Self> {
const JSON: &'static str = r#"
{
"arch": "arm",
Expand All @@ -186,7 +192,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])
Expand Down Expand Up @@ -367,6 +373,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 = "riscv32i-unknown-none-elf";

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.riscv32i-unknown-none-elf.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]
Expand Down

0 comments on commit d0dfcdc

Please sign in to comment.