2014-09-13 01:05:10 +00:00
|
|
|
use std::io::{fs, File, UserRWX};
|
2014-06-20 01:53:18 +00:00
|
|
|
|
2014-09-13 01:05:10 +00:00
|
|
|
use support::{ResultTest, project, execs, main_file, cargo_dir, path2url};
|
2014-09-05 17:15:10 +00:00
|
|
|
use support::{COMPILING, RUNNING};
|
2014-08-29 04:38:35 +00:00
|
|
|
use support::paths::{mod, PathExt};
|
2014-06-25 05:06:11 +00:00
|
|
|
use hamcrest::{assert_that, existing_file};
|
2014-06-18 00:05:29 +00:00
|
|
|
use cargo;
|
2014-06-18 00:40:22 +00:00
|
|
|
use cargo::util::{process};
|
2014-06-18 00:05:29 +00:00
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
}
|
|
|
|
|
|
|
|
test!(cargo_compile_with_nested_deps_shorthand {
|
2014-06-18 00:40:22 +00:00
|
|
|
let p = project("foo")
|
2014-06-18 00:05:29 +00:00
|
|
|
.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"
|
|
|
|
"#)
|
2014-06-19 23:45:19 +00:00
|
|
|
.file("src/foo.rs",
|
|
|
|
main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice())
|
2014-06-18 00:05:29 +00:00
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.baz]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
|
|
|
path = "baz"
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-18 00:05:29 +00:00
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
extern crate baz;
|
|
|
|
|
|
|
|
pub fn gimme() -> String {
|
|
|
|
baz::gimme()
|
|
|
|
}
|
|
|
|
"#)
|
2014-06-18 00:40:22 +00:00
|
|
|
.file("bar/baz/Cargo.toml", r#"
|
2014-06-18 00:05:29 +00:00
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "baz"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-18 00:05:29 +00:00
|
|
|
|
|
|
|
name = "baz"
|
|
|
|
"#)
|
2014-06-18 00:40:22 +00:00
|
|
|
.file("bar/baz/src/baz.rs", r#"
|
2014-06-18 00:05:29 +00:00
|
|
|
pub fn gimme() -> String {
|
2014-07-09 13:38:10 +00:00
|
|
|
"test passed".to_string()
|
2014-06-18 00:05:29 +00:00
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
|
|
|
|
{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, p.url(),
|
|
|
|
COMPILING, p.url(),
|
|
|
|
COMPILING, p.url())));
|
2014-06-18 00:05:29 +00:00
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
2014-06-18 00:05:29 +00:00
|
|
|
|
|
|
|
assert_that(
|
2014-06-25 05:06:11 +00:00
|
|
|
cargo::util::process(p.bin("foo")),
|
2014-06-18 00:05:29 +00:00
|
|
|
execs().with_stdout("test passed\n"));
|
|
|
|
})
|
2014-06-20 01:53:18 +00:00
|
|
|
|
2014-07-03 01:13:00 +00:00
|
|
|
test!(cargo_compile_with_root_dev_deps {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dev-dependencies.bar]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
2014-07-10 19:08:13 +00:00
|
|
|
path = "../bar"
|
2014-07-03 01:13:00 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
2014-07-10 19:08:13 +00:00
|
|
|
.file("src/main.rs",
|
|
|
|
main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice());
|
|
|
|
let p2 = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
2014-07-03 01:13:00 +00:00
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
"#)
|
2014-07-10 19:08:13 +00:00
|
|
|
.file("src/lib.rs", r#"
|
2014-07-03 01:13:00 +00:00
|
|
|
pub fn gimme() -> &'static str {
|
|
|
|
"zoidberg"
|
|
|
|
}
|
2014-07-10 19:08:13 +00:00
|
|
|
"#);
|
2014-07-03 01:13:00 +00:00
|
|
|
|
2014-07-10 19:08:13 +00:00
|
|
|
p2.build();
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-11 04:36:29 +00:00
|
|
|
execs().with_status(101))
|
|
|
|
})
|
2014-07-03 01:13:00 +00:00
|
|
|
|
2014-08-11 04:36:29 +00:00
|
|
|
test!(cargo_compile_with_root_dev_deps_with_testing {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
2014-07-03 01:13:00 +00:00
|
|
|
|
2014-08-11 04:36:29 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dev-dependencies.bar]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
|
|
|
path = "../bar"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs",
|
|
|
|
main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice());
|
|
|
|
let p2 = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
pub fn gimme() -> &'static str {
|
|
|
|
"zoidberg"
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
|
|
|
p2.build();
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("test"),
|
2014-08-11 04:36:29 +00:00
|
|
|
execs().with_stdout(format!("\
|
|
|
|
{compiling} bar v0.5.0 ({url})
|
|
|
|
{compiling} foo v0.5.0 ({url})
|
2014-08-19 04:38:04 +00:00
|
|
|
{running} target[..]foo-[..]
|
2014-08-11 04:36:29 +00:00
|
|
|
|
|
|
|
running 0 tests
|
|
|
|
|
|
|
|
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
|
|
|
|
|
|
|
|
", compiling = COMPILING, url = p.url(), running = RUNNING)));
|
2014-07-03 01:13:00 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(cargo_compile_with_transitive_dev_deps {
|
2014-07-02 23:58:25 +00:00
|
|
|
let p = project("foo")
|
|
|
|
.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"]
|
|
|
|
|
|
|
|
[dev-dependencies.baz]
|
|
|
|
|
2014-07-25 02:14:18 +00:00
|
|
|
git = "git://example.com/path/to/nowhere"
|
2014-07-02 23:58:25 +00:00
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-07-02 23:58:25 +00:00
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
pub fn gimme() -> &'static str {
|
|
|
|
"zoidberg"
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, p.url(),
|
|
|
|
COMPILING, p.url())));
|
2014-07-02 23:58:25 +00:00
|
|
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
cargo::util::process(p.bin("foo")),
|
|
|
|
execs().with_stdout("zoidberg\n"));
|
|
|
|
})
|
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
test!(no_rebuild_dependency {
|
|
|
|
let mut p = project("foo");
|
|
|
|
let bar = p.root().join("bar");
|
|
|
|
p = p
|
|
|
|
.file(".cargo/config", format!(r#"
|
2014-07-16 15:08:55 +00:00
|
|
|
paths = ['{}']
|
|
|
|
"#, bar.display()).as_slice())
|
2014-06-20 01:53:18 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[[bin]] name = "foo"
|
2014-06-23 15:39:50 +00:00
|
|
|
[dependencies] bar = "0.5.0"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("src/foo.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() { bar::bar() }
|
|
|
|
"#)
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib] name = "bar"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
pub fn bar() {}
|
|
|
|
"#);
|
2014-08-06 16:21:10 +00:00
|
|
|
let bar = path2url(bar);
|
2014-06-20 01:53:18 +00:00
|
|
|
// First time around we should compile both foo and bar
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-06-20 01:53:18 +00:00
|
|
|
// This time we shouldn't compile bar
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-05 17:15:10 +00:00
|
|
|
execs().with_stdout(""));
|
2014-08-02 07:08:31 +00:00
|
|
|
p.root().move_into_the_past().assert();
|
2014-06-20 01:53:18 +00:00
|
|
|
|
|
|
|
p.build(); // rebuild the files (rewriting them in the process)
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-06-20 01:53:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(deep_dependencies_trigger_rebuild {
|
|
|
|
let mut p = project("foo");
|
|
|
|
let bar = p.root().join("bar");
|
|
|
|
let baz = p.root().join("baz");
|
|
|
|
p = p
|
|
|
|
.file(".cargo/config", format!(r#"
|
2014-07-16 15:08:55 +00:00
|
|
|
paths = ['{}', '{}']
|
|
|
|
"#, bar.display(), baz.display()).as_slice())
|
2014-06-20 01:53:18 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-06-23 15:39:50 +00:00
|
|
|
[[bin]]
|
|
|
|
name = "foo"
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.5.0"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("src/foo.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() { bar::bar() }
|
|
|
|
"#)
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-23 15:39:50 +00:00
|
|
|
name = "bar"
|
|
|
|
[dependencies]
|
|
|
|
baz = "0.5.0"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
extern crate baz;
|
|
|
|
pub fn bar() { baz::baz() }
|
|
|
|
"#)
|
|
|
|
.file("baz/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "baz"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-23 15:39:50 +00:00
|
|
|
name = "baz"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("baz/src/baz.rs", r#"
|
|
|
|
pub fn baz() {}
|
|
|
|
"#);
|
2014-08-06 16:21:10 +00:00
|
|
|
let baz = path2url(baz);
|
|
|
|
let bar = path2url(bar);
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
|
|
|
|
{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, baz,
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-05 17:15:10 +00:00
|
|
|
execs().with_stdout(""));
|
2014-06-20 01:53:18 +00:00
|
|
|
|
|
|
|
// Make sure an update to baz triggers a rebuild of bar
|
|
|
|
//
|
|
|
|
// We base recompilation off mtime, so sleep for at least a second to ensure
|
|
|
|
// that this write will change the mtime.
|
2014-08-02 07:08:31 +00:00
|
|
|
p.root().move_into_the_past().assert();
|
2014-06-20 01:53:18 +00:00
|
|
|
File::create(&p.root().join("baz/src/baz.rs")).write_str(r#"
|
|
|
|
pub fn baz() { println!("hello!"); }
|
|
|
|
"#).assert();
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
|
|
|
|
{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, baz,
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-06-20 01:53:18 +00:00
|
|
|
|
|
|
|
// Make sure an update to bar doesn't trigger baz
|
2014-08-02 07:08:31 +00:00
|
|
|
p.root().move_into_the_past().assert();
|
2014-06-20 01:53:18 +00:00
|
|
|
File::create(&p.root().join("bar/src/bar.rs")).write_str(r#"
|
|
|
|
extern crate baz;
|
|
|
|
pub fn bar() { println!("hello!"); baz::baz(); }
|
|
|
|
"#).assert();
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-05 17:15:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
2014-08-06 16:21:10 +00:00
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-09-05 17:15:10 +00:00
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test!(no_rebuild_two_deps {
|
|
|
|
let mut p = project("foo");
|
|
|
|
let bar = p.root().join("bar");
|
|
|
|
let baz = p.root().join("baz");
|
|
|
|
p = p
|
|
|
|
.file(".cargo/config", format!(r#"
|
2014-07-16 15:08:55 +00:00
|
|
|
paths = ['{}', '{}']
|
|
|
|
"#, bar.display(), baz.display()).as_slice())
|
2014-06-20 01:53:18 +00:00
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-06-23 15:39:50 +00:00
|
|
|
[[bin]]
|
|
|
|
name = "foo"
|
|
|
|
[dependencies]
|
|
|
|
bar = "0.5.0"
|
|
|
|
baz = "0.5.0"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("src/foo.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
fn main() { bar::bar() }
|
|
|
|
"#)
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-23 15:39:50 +00:00
|
|
|
name = "bar"
|
|
|
|
[dependencies]
|
|
|
|
baz = "0.5.0"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("bar/src/bar.rs", r#"
|
|
|
|
pub fn bar() {}
|
|
|
|
"#)
|
|
|
|
.file("baz/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "baz"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-23 15:39:50 +00:00
|
|
|
name = "baz"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("baz/src/baz.rs", r#"
|
|
|
|
pub fn baz() {}
|
|
|
|
"#);
|
2014-08-06 16:21:10 +00:00
|
|
|
let baz = path2url(baz);
|
|
|
|
let bar = path2url(bar);
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} baz v0.5.0 ({})\n\
|
|
|
|
{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, baz,
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-07-18 02:53:47 +00:00
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-05 17:15:10 +00:00
|
|
|
execs().with_stdout(""));
|
2014-07-18 02:53:47 +00:00
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
2014-06-20 01:53:18 +00:00
|
|
|
})
|
2014-06-25 18:53:19 +00:00
|
|
|
|
|
|
|
test!(nested_deps_recompile {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
|
|
|
path = "src/bar"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
"#)
|
|
|
|
.file("src/foo.rs",
|
|
|
|
main_file(r#""{}", bar::gimme()"#, ["bar"]).as_slice())
|
|
|
|
.file("src/bar/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-06-25 18:53:19 +00:00
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/bar/src/bar.rs", "pub fn gimme() {}");
|
2014-08-06 16:21:10 +00:00
|
|
|
let bar = p.url();
|
2014-06-25 18:53:19 +00:00
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-08-06 16:21:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, bar,
|
|
|
|
COMPILING, p.url())));
|
2014-08-02 07:08:31 +00:00
|
|
|
p.root().move_into_the_past().assert();
|
|
|
|
|
2014-06-25 18:53:19 +00:00
|
|
|
File::create(&p.root().join("src/foo.rs")).write_str(r#"
|
|
|
|
fn main() {}
|
|
|
|
"#).assert();
|
|
|
|
|
|
|
|
// This shouldn't recompile `bar`
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-05 17:15:10 +00:00
|
|
|
execs().with_stdout(format!("{} foo v0.5.0 ({})\n",
|
2014-08-06 16:21:10 +00:00
|
|
|
COMPILING, p.url())));
|
2014-06-25 18:53:19 +00:00
|
|
|
})
|
2014-06-28 09:25:32 +00:00
|
|
|
|
|
|
|
test!(error_message_for_missing_manifest {
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
|
|
|
|
path = "src/bar"
|
2014-07-06 00:10:23 +00:00
|
|
|
|
2014-08-14 06:08:02 +00:00
|
|
|
[lib]
|
2014-07-06 00:10:23 +00:00
|
|
|
|
|
|
|
name = "foo"
|
2014-06-28 09:25:32 +00:00
|
|
|
"#)
|
|
|
|
.file("src/bar/not-a-manifest", "");
|
|
|
|
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"),
|
2014-06-28 09:25:32 +00:00
|
|
|
execs()
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(format!("Could not find `Cargo.toml` in `{}`\n",
|
|
|
|
p.root().join_many(&["src", "bar"]).display())));
|
|
|
|
|
|
|
|
})
|
2014-07-23 15:49:02 +00:00
|
|
|
|
2014-08-29 04:38:35 +00:00
|
|
|
test!(override_relative {
|
|
|
|
let bar = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
fs::mkdir(&paths::root().join(".cargo"), UserRWX).assert();
|
|
|
|
File::create(&paths::root().join(".cargo/config")).write_str(r#"
|
|
|
|
paths = ["bar"]
|
|
|
|
"#).assert();
|
|
|
|
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = '{}'
|
|
|
|
"#, bar.root().display()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
bar.build();
|
|
|
|
assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
|
|
|
|
|
|
|
|
})
|
|
|
|
|
2014-07-23 15:49:02 +00:00
|
|
|
test!(override_self {
|
|
|
|
let bar = project("bar")
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
let p = project("foo");
|
|
|
|
let root = p.root().clone();
|
|
|
|
let p = p
|
|
|
|
.file(".cargo/config", format!(r#"
|
|
|
|
paths = ['{}']
|
|
|
|
"#, root.display()))
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = '{}'
|
|
|
|
|
|
|
|
"#, bar.root().display()))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
|
|
|
|
|
|
|
bar.build();
|
2014-08-21 16:24:34 +00:00
|
|
|
assert_that(p.cargo_process("build"), execs().with_status(0));
|
2014-07-23 15:49:02 +00:00
|
|
|
|
|
|
|
})
|
2014-08-29 03:38:19 +00:00
|
|
|
|
|
|
|
test!(override_path_dep {
|
|
|
|
let bar = project("bar")
|
|
|
|
.file("p1/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "p1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.p2]
|
|
|
|
path = "../p2"
|
|
|
|
"#)
|
|
|
|
.file("p1/src/lib.rs", "")
|
|
|
|
.file("p2/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "p2"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("p2/src/lib.rs", "");
|
|
|
|
|
|
|
|
let p = project("foo")
|
|
|
|
.file(".cargo/config", format!(r#"
|
|
|
|
paths = ['{}', '{}']
|
|
|
|
"#, bar.root().join("p1").display(),
|
|
|
|
bar.root().join("p2").display()))
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.p2]
|
|
|
|
path = '{}'
|
|
|
|
|
|
|
|
"#, bar.root().join("p2").display()))
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
|
|
|
bar.build();
|
|
|
|
assert_that(p.cargo_process("build").arg("-v"),
|
|
|
|
execs().with_status(0));
|
|
|
|
|
|
|
|
})
|
2014-09-11 22:42:46 +00:00
|
|
|
|
|
|
|
test!(path_dep_build_cmd {
|
2014-09-13 01:05:10 +00:00
|
|
|
let p = project("foo")
|
2014-09-11 22:42:46 +00:00
|
|
|
.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_that(p.cargo_process("build"),
|
2014-09-13 01:05:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, p.url(),
|
|
|
|
COMPILING, p.url())));
|
2014-09-11 22:42:46 +00:00
|
|
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
|
2014-09-13 01:05:10 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 ({})\n\
|
|
|
|
{} foo v0.5.0 ({})\n",
|
|
|
|
COMPILING, p.url(),
|
|
|
|
COMPILING, p.url())));
|
2014-09-11 22:42:46 +00:00
|
|
|
|
|
|
|
assert_that(
|
|
|
|
cargo::util::process(p.bin("foo")),
|
|
|
|
execs().with_stdout("1\n"));
|
|
|
|
})
|
|
|
|
|