From b4adda4d153ba5c876cbb02c79bfa3651edf80db Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 12 Sep 2014 15:21:23 -0700 Subject: [PATCH] Test for build commands in git subdirs --- tests/test_cargo_compile_git_deps.rs | 58 ++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/test_cargo_compile_git_deps.rs b/tests/test_cargo_compile_git_deps.rs index 0822a7af1..0ad20e5cc 100644 --- a/tests/test_cargo_compile_git_deps.rs +++ b/tests/test_cargo_compile_git_deps.rs @@ -1143,3 +1143,61 @@ test!(git_repo_changing_no_rebuild { assert_that(p1.process(cargo_dir().join("cargo")).arg("build"), execs().with_stdout("")); }) + +test!(git_dep_build_cmd { + let p = git_repo("foo", |project| { + project.file("Cargo.toml", r#" + [project] + + name = "foo" + version = "0.5.0" + authors = ["wycats@example.com"] + + [dependencies.bar] + + version = "0.5.0" + path = "bar" + + [[bin]] + + name = "foo" + "#) + .file("src/foo.rs", + main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice()) + .file("bar/Cargo.toml", r#" + [project] + + name = "bar" + version = "0.5.0" + authors = ["wycats@example.com"] + build = "cp src/bar.rs.in src/bar.rs" + + [lib] + + name = "bar" + "#) + .file("bar/src/bar.rs.in", r#" + pub fn gimme() -> int { 0 } + "#) + }).assert(); + + assert_that(p.process(cargo_dir().join("cargo")).arg("build"), + execs().with_status(0)); + + assert_that( + cargo::util::process(p.bin("foo")), + execs().with_stdout("0\n")); + + // Touching bar.rs.in should cause the `build` command to run again. + let mut file = fs::File::create(&p.root().join("bar/src/bar.rs.in")).assert(); + file.write_str(r#"pub fn gimme() -> int { 1 }"#).assert(); + drop(file); + + assert_that(p.process(cargo_dir().join("cargo")).arg("build"), + execs().with_status(0)); + + assert_that( + cargo::util::process(p.bin("foo")), + execs().with_stdout("1\n")); +}) +