2014-07-22 15:33:47 +00:00
|
|
|
use std::io::File;
|
2014-07-25 02:14:18 +00:00
|
|
|
use std::path;
|
2014-06-19 07:55:17 +00:00
|
|
|
|
|
|
|
use support::{ProjectBuilder, ResultTest, project, execs, main_file, paths};
|
2014-07-16 15:08:55 +00:00
|
|
|
use support::{cargo_dir};
|
2014-06-26 22:14:31 +00:00
|
|
|
use support::{COMPILING, FRESH, UPDATING};
|
2014-06-12 22:51:16 +00:00
|
|
|
use hamcrest::{assert_that,existing_file};
|
|
|
|
use cargo;
|
2014-06-19 08:21:24 +00:00
|
|
|
use cargo::util::{ProcessError, process};
|
2014-06-12 22:51:16 +00:00
|
|
|
|
|
|
|
fn setup() {
|
|
|
|
}
|
|
|
|
|
2014-06-19 23:45:19 +00:00
|
|
|
fn git_repo(name: &str, callback: |ProjectBuilder| -> ProjectBuilder)
|
|
|
|
-> Result<ProjectBuilder, ProcessError>
|
|
|
|
{
|
2014-06-19 07:55:17 +00:00
|
|
|
let gitconfig = paths::home().join(".gitconfig");
|
|
|
|
|
|
|
|
if !gitconfig.exists() {
|
|
|
|
File::create(&gitconfig).write(r"
|
|
|
|
[user]
|
|
|
|
|
|
|
|
email = foo@bar.com
|
|
|
|
name = Foo Bar
|
|
|
|
".as_bytes()).assert()
|
|
|
|
}
|
|
|
|
|
2014-06-12 22:51:16 +00:00
|
|
|
let mut git_project = project(name);
|
|
|
|
git_project = callback(git_project);
|
|
|
|
git_project.build();
|
|
|
|
|
|
|
|
log!(5, "git init");
|
|
|
|
try!(git_project.process("git").args(["init"]).exec_with_output());
|
|
|
|
log!(5, "building git project");
|
|
|
|
log!(5, "git add .");
|
|
|
|
try!(git_project.process("git").args(["add", "."]).exec_with_output());
|
|
|
|
log!(5, "git commit");
|
2014-06-19 23:45:19 +00:00
|
|
|
try!(git_project.process("git").args(["commit", "-m", "Initial commit"])
|
|
|
|
.exec_with_output());
|
2014-06-12 22:51:16 +00:00
|
|
|
Ok(git_project)
|
|
|
|
}
|
|
|
|
|
|
|
|
test!(cargo_compile_simple_git_dep {
|
|
|
|
let project = project("foo");
|
|
|
|
let git_project = git_repo("dep1", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
"#)
|
|
|
|
.file("src/dep1.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
let project = project
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep1]
|
|
|
|
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-06-12 22:51:16 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display()))
|
2014-06-12 22:51:16 +00:00
|
|
|
.file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
|
|
|
|
|
|
|
|
let root = project.root();
|
|
|
|
let git_root = git_project.root();
|
|
|
|
|
2014-07-07 22:17:34 +00:00
|
|
|
assert_that(project.cargo_process("cargo-build"),
|
2014-06-12 22:51:16 +00:00
|
|
|
execs()
|
2014-06-22 05:22:56 +00:00
|
|
|
.with_stdout(format!("{} git repository `file:{}`\n\
|
|
|
|
{} dep1 v0.5.0 (file:{})\n\
|
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_root.display(),
|
|
|
|
COMPILING, git_root.display(),
|
|
|
|
COMPILING, root.display()))
|
2014-06-12 22:51:16 +00:00
|
|
|
.with_stderr(""));
|
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(&project.bin("foo"), existing_file());
|
2014-06-12 22:51:16 +00:00
|
|
|
|
|
|
|
assert_that(
|
2014-06-25 05:06:11 +00:00
|
|
|
cargo::util::process(project.bin("foo")),
|
2014-06-12 22:51:16 +00:00
|
|
|
execs().with_stdout("hello world\n"));
|
|
|
|
})
|
2014-06-18 00:40:22 +00:00
|
|
|
|
2014-07-25 02:14:18 +00:00
|
|
|
test!(override_git_dep {
|
|
|
|
let p = project("foo");
|
|
|
|
let root = p.root().clone();
|
|
|
|
let p = p
|
|
|
|
.file(".cargo/config", format!(r#"
|
|
|
|
paths = ['{}/baz']
|
|
|
|
"#, root.display()))
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "bar"
|
|
|
|
"#)
|
|
|
|
.file("src/main.rs", "extern crate bar; fn main() {}")
|
|
|
|
.file("bar/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.baz]
|
|
|
|
git = 'git://example.com/path/to/nowhere'
|
|
|
|
"#)
|
|
|
|
.file("bar/src/lib.rs", "extern crate baz;")
|
|
|
|
.file("baz/Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
|
|
|
|
name = "baz"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
"#)
|
|
|
|
.file("baz/src/lib.rs", "");
|
|
|
|
|
|
|
|
assert_that(p.cargo_process("cargo-build"),
|
|
|
|
execs()
|
|
|
|
.with_stdout(format!("{compiling} baz v0.5.0 (file:{dir}{sep}baz)\n\
|
|
|
|
{compiling} bar v0.5.0 (file:{dir})\n\
|
|
|
|
{compiling} foo v0.5.0 (file:{dir})\n",
|
|
|
|
compiling = COMPILING, dir = root.display(),
|
|
|
|
sep = path::SEP))
|
|
|
|
.with_stderr(""));
|
|
|
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
cargo::util::process(p.bin("foo")),
|
|
|
|
execs().with_stdout(""));
|
|
|
|
})
|
|
|
|
|
2014-06-24 22:23:03 +00:00
|
|
|
test!(cargo_compile_git_dep_branch {
|
|
|
|
let project = project("foo");
|
|
|
|
let git_project = git_repo("dep1", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
"#)
|
|
|
|
.file("src/dep1.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
git_project.process("git").args(["checkout", "-b", "branchy"]).exec_with_output().assert();
|
|
|
|
git_project.process("git").args(["branch", "-d", "master"]).exec_with_output().assert();
|
|
|
|
|
|
|
|
let project = project
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep1]
|
|
|
|
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-06-24 22:23:03 +00:00
|
|
|
branch = "branchy"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display()))
|
2014-06-24 22:23:03 +00:00
|
|
|
.file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
|
|
|
|
|
|
|
|
let root = project.root();
|
|
|
|
let git_root = git_project.root();
|
|
|
|
|
|
|
|
assert_that(project.cargo_process("cargo-build"),
|
|
|
|
execs()
|
|
|
|
.with_stdout(format!("{} git repository `file:{}`\n\
|
2014-07-08 21:58:56 +00:00
|
|
|
{} dep1 v0.5.0 (file:{}#ref=branchy)\n\
|
2014-06-24 22:23:03 +00:00
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_root.display(),
|
|
|
|
COMPILING, git_root.display(),
|
|
|
|
COMPILING, root.display()))
|
|
|
|
.with_stderr(""));
|
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(&project.bin("foo"), existing_file());
|
2014-06-24 22:23:03 +00:00
|
|
|
|
|
|
|
assert_that(
|
2014-06-25 05:06:11 +00:00
|
|
|
cargo::util::process(project.bin("foo")),
|
2014-06-24 22:23:03 +00:00
|
|
|
execs().with_stdout("hello world\n"));
|
|
|
|
})
|
|
|
|
|
|
|
|
test!(cargo_compile_git_dep_tag {
|
|
|
|
let project = project("foo");
|
|
|
|
let git_project = git_repo("dep1", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
"#)
|
|
|
|
.file("src/dep1.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
git_project.process("git").args(["tag", "v0.1.0"]).exec_with_output().assert();
|
|
|
|
git_project.process("git").args(["checkout", "-b", "tmp"]).exec_with_output().assert();
|
|
|
|
git_project.process("git").args(["branch", "-d", "master"]).exec_with_output().assert();
|
|
|
|
|
|
|
|
let project = project
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep1]
|
|
|
|
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-06-24 22:23:03 +00:00
|
|
|
tag = "v0.1.0"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display()))
|
2014-06-24 22:23:03 +00:00
|
|
|
.file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
|
|
|
|
|
|
|
|
let root = project.root();
|
|
|
|
let git_root = git_project.root();
|
|
|
|
|
|
|
|
assert_that(project.cargo_process("cargo-build"),
|
|
|
|
execs()
|
|
|
|
.with_stdout(format!("{} git repository `file:{}`\n\
|
2014-07-08 21:58:56 +00:00
|
|
|
{} dep1 v0.5.0 (file:{}#ref=v0.1.0)\n\
|
2014-06-24 22:23:03 +00:00
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_root.display(),
|
|
|
|
COMPILING, git_root.display(),
|
|
|
|
COMPILING, root.display()))
|
|
|
|
.with_stderr(""));
|
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(&project.bin("foo"), existing_file());
|
2014-06-24 22:23:03 +00:00
|
|
|
|
|
|
|
assert_that(
|
2014-06-25 05:06:11 +00:00
|
|
|
cargo::util::process(project.bin("foo")),
|
2014-06-24 22:23:03 +00:00
|
|
|
execs().with_stdout("hello world\n"));
|
|
|
|
})
|
2014-07-01 01:36:27 +00:00
|
|
|
|
2014-06-18 00:40:22 +00:00
|
|
|
test!(cargo_compile_with_nested_paths {
|
|
|
|
let git_project = git_repo("dep1", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep2]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
|
|
|
path = "vendor/dep2"
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
"#)
|
|
|
|
.file("src/dep1.rs", r#"
|
|
|
|
extern crate dep2;
|
|
|
|
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
dep2::hello()
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.file("vendor/dep2/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep2"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep2"
|
|
|
|
"#)
|
|
|
|
.file("vendor/dep2/src/dep2.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
let p = project("parent")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "parent"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep1]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-06-18 00:40:22 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "parent"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display()))
|
2014-06-19 23:45:19 +00:00
|
|
|
.file("src/parent.rs",
|
|
|
|
main_file(r#""{}", dep1::hello()"#, ["dep1"]).as_slice());
|
2014-06-18 00:40:22 +00:00
|
|
|
|
2014-06-24 02:09:12 +00:00
|
|
|
p.cargo_process("cargo-build")
|
2014-06-18 00:40:22 +00:00
|
|
|
.exec_with_output()
|
|
|
|
.assert();
|
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(&p.bin("parent"), existing_file());
|
2014-06-18 00:40:22 +00:00
|
|
|
|
|
|
|
assert_that(
|
2014-06-25 05:06:11 +00:00
|
|
|
cargo::util::process(p.bin("parent")),
|
2014-06-18 00:40:22 +00:00
|
|
|
execs().with_stdout("hello world\n"));
|
|
|
|
})
|
2014-06-20 01:53:18 +00:00
|
|
|
|
2014-07-01 01:36:27 +00:00
|
|
|
test!(cargo_compile_with_meta_package {
|
|
|
|
let git_project = git_repo("meta-dep", |project| {
|
|
|
|
project
|
|
|
|
.file("dep1/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep1"
|
|
|
|
"#)
|
|
|
|
.file("dep1/src/dep1.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"this is dep1"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.file("dep2/Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "dep2"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
|
|
|
[[lib]]
|
|
|
|
|
|
|
|
name = "dep2"
|
|
|
|
"#)
|
|
|
|
.file("dep2/src/dep2.rs", r#"
|
|
|
|
pub fn hello() -> &'static str {
|
|
|
|
"this is dep2"
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
let p = project("parent")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "parent"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep1]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-07-01 01:36:27 +00:00
|
|
|
|
|
|
|
[dependencies.dep2]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-07-01 01:36:27 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "parent"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display(), git_project.root().display()))
|
2014-07-01 01:36:27 +00:00
|
|
|
.file("src/parent.rs",
|
|
|
|
main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, ["dep1", "dep2"]).as_slice());
|
|
|
|
|
|
|
|
p.cargo_process("cargo-build")
|
|
|
|
.exec_with_output()
|
|
|
|
.assert();
|
|
|
|
|
|
|
|
assert_that(&p.bin("parent"), existing_file());
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
cargo::util::process(p.bin("parent")),
|
|
|
|
execs().with_stdout("this is dep1 this is dep2\n"));
|
|
|
|
})
|
|
|
|
|
2014-06-27 03:51:25 +00:00
|
|
|
test!(cargo_compile_with_short_ssh_git {
|
|
|
|
let url = "git@github.com:a/dep";
|
|
|
|
|
|
|
|
let project = project("project")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.dep]
|
|
|
|
|
|
|
|
git = "{}"
|
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
"#, url))
|
|
|
|
.file("src/foo.rs", main_file(r#""{}", dep1::hello()"#, ["dep1"]));
|
|
|
|
|
|
|
|
assert_that(project.cargo_process("cargo-build"),
|
|
|
|
execs()
|
|
|
|
.with_stdout("")
|
|
|
|
.with_stderr(format!("Cargo.toml is not a valid manifest\n\n\
|
2014-07-30 16:52:37 +00:00
|
|
|
invalid url `{}`: `Relative URL without a base\n", url)));
|
2014-06-27 03:51:25 +00:00
|
|
|
})
|
|
|
|
|
2014-07-11 20:32:27 +00:00
|
|
|
test!(two_revs_same_deps {
|
|
|
|
let bar = git_repo("meta-dep", |project| {
|
|
|
|
project.file("Cargo.toml", r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
"#)
|
|
|
|
.file("src/lib.rs", "pub fn bar() -> int { 1 }")
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
// Commit the changes and make sure we trigger a recompile
|
|
|
|
let rev1 = bar.process("git").args(["rev-parse", "HEAD"])
|
|
|
|
.exec_with_output().assert();
|
|
|
|
File::create(&bar.root().join("src/lib.rs")).write_str(r#"
|
|
|
|
pub fn bar() -> int { 2 }
|
|
|
|
"#).assert();
|
|
|
|
bar.process("git").args(["add", "."]).exec_with_output().assert();
|
|
|
|
bar.process("git").args(["commit", "-m", "test"]).exec_with_output()
|
|
|
|
.assert();
|
|
|
|
let rev2 = bar.process("git").args(["rev-parse", "HEAD"])
|
|
|
|
.exec_with_output().assert();
|
|
|
|
|
|
|
|
let rev1 = String::from_utf8(rev1.output).unwrap();
|
|
|
|
let rev2 = String::from_utf8(rev2.output).unwrap();
|
|
|
|
|
|
|
|
let foo = project("foo")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-07-11 20:32:27 +00:00
|
|
|
rev = "{}"
|
|
|
|
|
|
|
|
[dependencies.baz]
|
|
|
|
path = "../baz"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, bar.root().display(), rev1.as_slice().trim()).as_slice())
|
2014-07-11 20:32:27 +00:00
|
|
|
.file("src/main.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
extern crate baz;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(bar::bar(), 1);
|
|
|
|
assert_eq!(baz::baz(), 2);
|
|
|
|
}
|
|
|
|
"#);
|
|
|
|
|
|
|
|
let baz = project("baz")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[package]
|
|
|
|
name = "baz"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-07-11 20:32:27 +00:00
|
|
|
rev = "{}"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, bar.root().display(), rev2.as_slice().trim()).as_slice())
|
2014-07-11 20:32:27 +00:00
|
|
|
.file("src/lib.rs", r#"
|
|
|
|
extern crate bar;
|
|
|
|
pub fn baz() -> int { bar::bar() }
|
|
|
|
"#);
|
|
|
|
|
|
|
|
baz.build();
|
|
|
|
|
|
|
|
// TODO: -j1 is a hack
|
|
|
|
assert_that(foo.cargo_process("cargo-build").arg("-j").arg("1"),
|
|
|
|
execs().with_status(0));
|
2014-07-17 01:44:30 +00:00
|
|
|
assert_that(&foo.bin("foo"), existing_file());
|
|
|
|
assert_that(foo.process(foo.bin("foo")), execs().with_status(0));
|
2014-07-11 20:32:27 +00:00
|
|
|
})
|
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
test!(recompilation {
|
|
|
|
let git_project = git_repo("bar", |project| {
|
|
|
|
project
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "bar"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["carlhuda@example.com"]
|
|
|
|
|
2014-06-23 15:39:50 +00:00
|
|
|
[[lib]]
|
|
|
|
name = "bar"
|
2014-06-20 01:53:18 +00:00
|
|
|
"#)
|
|
|
|
.file("src/bar.rs", r#"
|
|
|
|
pub fn bar() {}
|
|
|
|
"#)
|
|
|
|
}).assert();
|
|
|
|
|
|
|
|
let p = project("foo")
|
|
|
|
.file("Cargo.toml", format!(r#"
|
|
|
|
[project]
|
|
|
|
|
|
|
|
name = "foo"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = ["wycats@example.com"]
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
|
|
|
|
version = "0.5.0"
|
2014-07-16 15:08:55 +00:00
|
|
|
git = 'file:{}'
|
2014-06-20 01:53:18 +00:00
|
|
|
|
|
|
|
[[bin]]
|
|
|
|
|
|
|
|
name = "foo"
|
2014-07-16 15:08:55 +00:00
|
|
|
"#, git_project.root().display()))
|
2014-06-20 01:53:18 +00:00
|
|
|
.file("src/foo.rs",
|
|
|
|
main_file(r#""{}", bar::bar()"#, ["bar"]).as_slice());
|
|
|
|
|
|
|
|
// First time around we should compile both foo and bar
|
2014-06-24 02:09:12 +00:00
|
|
|
assert_that(p.cargo_process("cargo-build"),
|
2014-06-22 05:22:56 +00:00
|
|
|
execs().with_stdout(format!("{} git repository `file:{}`\n\
|
|
|
|
{} bar v0.5.0 (file:{})\n\
|
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_project.root().display(),
|
|
|
|
COMPILING, git_project.root().display(),
|
|
|
|
COMPILING, p.root().display())));
|
2014-06-24 01:54:13 +00:00
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
// Don't recompile the second time
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-build")),
|
2014-06-24 01:54:13 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
|
2014-06-22 05:22:56 +00:00
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
FRESH, git_project.root().display(),
|
|
|
|
FRESH, p.root().display())));
|
2014-06-24 01:54:13 +00:00
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
// Modify a file manually, shouldn't trigger a recompile
|
|
|
|
File::create(&git_project.root().join("src/bar.rs")).write_str(r#"
|
|
|
|
pub fn bar() { println!("hello!"); }
|
|
|
|
"#).assert();
|
2014-06-24 01:54:13 +00:00
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-build")),
|
2014-06-24 01:54:13 +00:00
|
|
|
execs().with_stdout(format!("{} bar v0.5.0 (file:{})\n\
|
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
FRESH, git_project.root().display(),
|
|
|
|
FRESH, p.root().display())));
|
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-build")).arg("-u"),
|
2014-06-22 05:22:56 +00:00
|
|
|
execs().with_stdout(format!("{} git repository `file:{}`\n\
|
|
|
|
{} bar v0.5.0 (file:{})\n\
|
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_project.root().display(),
|
|
|
|
FRESH, git_project.root().display(),
|
|
|
|
FRESH, p.root().display())));
|
2014-06-24 01:54:13 +00:00
|
|
|
|
2014-06-20 01:53:18 +00:00
|
|
|
// Commit the changes and make sure we trigger a recompile
|
|
|
|
File::create(&git_project.root().join("src/bar.rs")).write_str(r#"
|
|
|
|
pub fn bar() { println!("hello!"); }
|
|
|
|
"#).assert();
|
|
|
|
git_project.process("git").args(["add", "."]).exec_with_output().assert();
|
|
|
|
git_project.process("git").args(["commit", "-m", "test"]).exec_with_output()
|
|
|
|
.assert();
|
2014-06-24 01:54:13 +00:00
|
|
|
|
2014-06-25 05:06:11 +00:00
|
|
|
assert_that(p.process(cargo_dir().join("cargo-build")).arg("-u"),
|
2014-06-22 05:22:56 +00:00
|
|
|
execs().with_stdout(format!("{} git repository `file:{}`\n\
|
|
|
|
{} bar v0.5.0 (file:{})\n\
|
|
|
|
{} foo v0.5.0 (file:{})\n",
|
|
|
|
UPDATING, git_project.root().display(),
|
|
|
|
COMPILING, git_project.root().display(),
|
|
|
|
COMPILING, p.root().display())));
|
2014-06-20 01:53:18 +00:00
|
|
|
})
|