mirror of
https://github.com/rust-lang/cargo
synced 2024-10-14 19:52:45 +00:00
Test for build commands in git subdirs
This commit is contained in:
parent
8b07052b16
commit
b4adda4d15
|
@ -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"));
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue