let mut f = try!(File::open(path));
try!(f.read_to_string(&mut ret));
Ok(ret)
- }).chain_error(|| {
- internal(format!("failed to read `{}`", path.display()))
+ })().map_err(human).chain_error(|| {
+ human(format!("failed to read `{}`", path.display()))
})
}
let mut f = try!(File::create(path));
try!(f.write_all(contents));
Ok(())
- }).chain_error(|| {
- internal(format!("failed to write `{}`", path.display()))
+ })().map_err(human).chain_error(|| {
+ human(format!("failed to write `{}`", path.display()))
})
}
assert_that(p.cargo_process("build"),
execs()
- .with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ .with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url()))
assert_that(p.cargo_process("build"),
execs().with_status(101).with_stderr(&format!(
r#"no matching package named `notquitebar` found (required by `foo`)
-location searched: {proj_dir}
+location searched: {proj_dir}/bar
version required: *
"#, proj_dir = p.url())));
});
.file("foo/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(&format!("\
-{compiling} foo v0.0.0 ({url})
+{compiling} foo v0.0.0 ({url}/foo)
{running} `rustc foo[..]src[..]lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib -C prefer-dynamic \
-C opt-level=3 \
authors = []
[dependencies.a]
- path = "../b"
+ path = "../a"
"#)
.file("b/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v"),
execs().with_stdout(&format!("\
{updating} git repository `{git}`
{compiling} bar v0.5.0 ({git}#[..])
-{compiling} [..] v0.5.0 ({dir})
-{compiling} [..] v0.5.0 ({dir})
+{compiling} [..] v0.5.0 ([..])
+{compiling} [..] v0.5.0 ([..])
{compiling} foo v0.5.0 ({dir})\n",
updating = UPDATING, git = git_project.url(),
compiling = COMPILING, dir = p.url())));
assert_that(p.cargo("build"),
execs().with_stdout(&format!("\
{compiling} bar v0.5.0 ({git}#[..])
-{compiling} [..] v0.5.0 ({dir})
-{compiling} [..] v0.5.0 ({dir})
+{compiling} [..] v0.5.0 ({dir}[..]dep[..])
+{compiling} [..] v0.5.0 ({dir}[..]dep[..])
{compiling} foo v0.5.0 ({dir})\n",
git = git_project.url(),
compiling = COMPILING, dir = p.url())));
assert_that(p.cargo_process("build"),
execs().with_status(0)
- .with_stdout(&format!("{} baz v0.5.0 ({})\n\
- {} bar v0.5.0 ({})\n\
+ .with_stdout(&format!("{} baz v0.5.0 ({}/bar/baz)\n\
+ {} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url(),
println!("building baz");
assert_that(p.cargo("build").arg("-p").arg("baz"),
execs().with_status(0)
- .with_stdout(&format!("{} baz v0.5.0 ({})\n",
+ .with_stdout(&format!("{} baz v0.5.0 ({}/bar/baz)\n",
COMPILING, p.url())));
println!("building foo");
assert_that(p.cargo("build")
.arg("-p").arg("foo"),
execs().with_status(0)
- .with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ .with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
p2.build();
assert_that(p.cargo_process("test"),
execs().with_stdout(&format!("\
-{compiling} [..] v0.5.0 ({url})
-{compiling} [..] v0.5.0 ({url})
+{compiling} [..] v0.5.0 ([..])
+{compiling} [..] v0.5.0 ([..])
{running} target[..]foo-[..]
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
-", compiling = COMPILING, url = p.url(), running = RUNNING)));
+", compiling = COMPILING, running = RUNNING)));
});
test!(cargo_compile_with_transitive_dev_deps {
"#);
assert_that(p.cargo_process("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
"#);
// First time around we should compile both foo and bar
assert_that(p.cargo_process("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
p.build(); // rebuild the files (rewriting them in the process)
assert_that(p.cargo("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
pub fn baz() {}
"#);
assert_that(p.cargo_process("build"),
- execs().with_stdout(&format!("{} baz v0.5.0 ({})\n\
- {} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} baz v0.5.0 ({}/baz)\n\
+ {} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url(),
pub fn baz() { println!("hello!"); }
"#).unwrap();
assert_that(p.cargo("build"),
- execs().with_stdout(&format!("{} baz v0.5.0 ({})\n\
- {} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} baz v0.5.0 ({}/baz)\n\
+ {} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url(),
pub fn bar() { println!("hello!"); baz::baz(); }
"#).unwrap();
assert_that(p.cargo("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
pub fn baz() {}
"#);
assert_that(p.cargo_process("build"),
- execs().with_stdout(&format!("{} baz v0.5.0 ({})\n\
- {} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} baz v0.5.0 ({}/baz)\n\
+ {} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url(),
let bar = p.url();
assert_that(p.cargo_process("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/src/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, bar,
COMPILING, p.url())));
.file("src/bar/not-a-manifest", "");
assert_that(p.cargo_process("build"),
- execs()
- .with_status(101)
- .with_stderr(&format!("\
+ execs().with_status(101)
+ .with_stderr("\
Unable to update file://[..]
Caused by:
- Could not find `Cargo.toml` in `{}`
-", p.root().join("src").join("bar").display())));
+ failed to read `[..]bar[..]Cargo.toml`
+
+Caused by:
+ No such file or directory ([..])
+"));
});
p.root().join("bar").move_into_the_past().unwrap();
assert_that(p.cargo("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
}
assert_that(p.cargo("build"),
- execs().with_stdout(&format!("{} bar v0.5.0 ({})\n\
+ execs().with_stdout(&format!("{} bar v0.5.0 ({}/bar)\n\
{} foo v0.5.0 ({})\n",
COMPILING, p.url(),
COMPILING, p.url())));
assert_that(p.cargo("test"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} [..] v0.5.0 ({url})
-{compiling} [..] v0.5.0 ({url})
+{compiling} [..] v0.5.0 ({url}[..])
+{compiling} [..] v0.5.0 ({url}[..])
{running} target[..]foo-[..]
running 0 tests
foo.build();
assert_that(bar.cargo_process("build").arg("--verbose"),
execs().with_stdout(&format!("\
-{compiling} foo v0.0.1 ({url})
+{compiling} foo v0.0.1 ([..])
{running} `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
-", compiling = COMPILING, running = RUNNING, url = bar.url())))
+", compiling = COMPILING, running = RUNNING)));
});
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0)
.with_stdout_contains(&format!("\
-{compiling} d1 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
+{compiling} d1 v0.0.0 ({url}/d1)", compiling = COMPILING, url = p.url()))
.with_stdout_contains(&format!("\
{running} `rustc d1[..]build.rs [..] --out-dir {dir}[..]target[..]build[..]d1-[..]`",
running = RUNNING, dir = p.root().display()))
.with_stdout_contains(&format!("\
{running} `rustc d1[..]src[..]lib.rs [..]`", running = RUNNING))
.with_stdout_contains(&format!("\
-{compiling} d2 v0.0.0 ({url})", compiling = COMPILING, url = p.url()))
+{compiling} d2 v0.0.0 ({url}/d2)", compiling = COMPILING, url = p.url()))
.with_stdout_contains(&format!("\
{running} `rustc d2[..]src[..]lib.rs [..] \
-L /path/to/{host}`", running = RUNNING, host = host))
assert_that(p.cargo_process("doc"),
execs().with_status(0).with_stdout(&format!("\
-[..] bar v0.0.1 ({dir})
-[..] bar v0.0.1 ({dir})
+[..] bar v0.0.1 ({dir}/bar)
+[..] bar v0.0.1 ({dir}/bar)
{documenting} foo v0.0.1 ({dir})
",
documenting = DOCUMENTING,
assert_that(p.cargo_process("doc").arg("--no-deps"),
execs().with_status(0).with_stdout(&format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
{documenting} foo v0.0.1 ({dir})
",
documenting = DOCUMENTING, compiling = COMPILING,
assert_that(p.cargo("build").arg("--features").arg("bar"),
execs().with_status(0).with_stdout(format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url())));
assert_that(p.process(&p.bin("foo")),
assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url())));
assert_that(p.process(&p.bin("foo")),
assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
-{compiling} ba[..] v0.0.1 ({dir})
-{compiling} ba[..] v0.0.1 ({dir})
+{compiling} ba[..] v0.0.1 ({dir}/ba[..])
+{compiling} ba[..] v0.0.1 ({dir}/ba[..])
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url())));
});
assert_that(p.cargo_process("build").arg("--features").arg("bar baz"),
execs().with_status(0).with_stdout(format!("\
-{compiling} ba[..] v0.0.1 ({dir})
-{compiling} ba[..] v0.0.1 ({dir})
+{compiling} ba[..] v0.0.1 ({dir}/ba[..])
+{compiling} ba[..] v0.0.1 ({dir}/ba[..])
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url())));
});
assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
-{compiling} d2 v0.0.1 ({dir})
-{compiling} d1 v0.0.1 ({dir})
+{compiling} d2 v0.0.1 ({dir}/d2)
+{compiling} d1 v0.0.1 ({dir}/d1)
{compiling} foo v0.0.1 ({dir})
", compiling = COMPILING, dir = p.url())));
});
assert_that(p.cargo_process("build"),
execs().with_status(0).with_stdout(format!("\
-{compiling} a v0.1.0 ({dir})
+{compiling} a v0.1.0 ({dir}/a)
{compiling} b v0.1.0 ({dir})
", compiling = COMPILING, dir = p.url())));
p.root().move_into_the_past().unwrap();
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stdout(format!("\
-{fresh} a v0.1.0 ([..])
+{fresh} a v0.1.0 ([..]/a)
{fresh} b v0.1.0 ([..])
", fresh = FRESH)));
});
`[..]` is not a crate root; specify a crate to install [..]
Caused by:
- Could not find Cargo.toml in `[..]`
+ failed to read `[..]Cargo.toml`
+
+Caused by:
+ No such file or directory ([..])
"));
});
});
test!(multiple_crates_error {
- let p = project("foo")
+ let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
name = "foo"
.file("a/src/main.rs", "fn main() {}");
p.build();
- assert_that(cargo_process("install").arg("--path").arg(p.root()),
+ assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
execs().with_status(101).with_stderr("\
multiple packages with binaries found: bar, foo
"));
});
test!(multiple_crates_select {
- let p = project("foo")
+ let p = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[package]
name = "foo"
.file("a/src/main.rs", "fn main() {}");
p.build();
- assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"),
+ assert_that(cargo_process("install").arg("--git").arg(p.url().to_string())
+ .arg("foo"),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
assert_that(cargo_home(), is_not(has_installed_exe("bar")));
- assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("bar"),
+ assert_that(cargo_process("install").arg("--git").arg(p.url().to_string())
+ .arg("bar"),
execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("bar"));
});
.file("src/main.rs", "fn main() {}");
p.build();
- assert_that(cargo_process("install"), execs().with_status(0));
+ assert_that(cargo_process("install").cwd(p.root()),
+ execs().with_status(0));
assert_that(cargo_home(), has_installed_exe("foo"));
});
let mut cargo = ::cargo_process();
cargo.cwd(p.root());
assert_that(cargo.clone().arg("build"), execs().with_status(0));
- assert_that(cargo.arg("package").arg("-v").arg("--no-verify"),
+
+ println!("package main repo");
+ assert_that(cargo.clone().arg("package").arg("-v").arg("--no-verify"),
execs().with_status(0).with_stdout(&format!("\
{packaging} foo v0.0.1 ([..])
{archiving} [..]
{archiving} [..]
+",
+ packaging = PACKAGING,
+ archiving = ARCHIVING)));
+
+ println!("package sub-repo");
+ assert_that(cargo.arg("package").arg("-v").arg("--no-verify")
+ .cwd(p.root().join("a")),
+ execs().with_status(0).with_stdout(&format!("\
+{packaging} a v0.0.1 ([..])
+{archiving} [..]
+{archiving} [..]
",
packaging = PACKAGING,
archiving = ARCHIVING)));
.file("foo/src/lib.rs", "");
assert_that(p.cargo_process("build").arg("-v").arg("--release"),
execs().with_status(0).with_stdout(&format!("\
-{compiling} foo v0.0.0 ({url})
+{compiling} foo v0.0.0 ({url}/foo)
{running} `rustc foo{sep}src{sep}lib.rs --crate-name foo \
--crate-type dylib --crate-type rlib -C prefer-dynamic \
-C opt-level=1 \
{updating} registry `[..]`
{downloading} bar v0.0.1 (registry file://[..])
{compiling} bar v0.0.1 (registry file://[..])
-{compiling} a v0.0.1 ({dir})
+{compiling} a v0.0.1 ({dir}/a)
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url())));
{updating} registry `[..]`
{downloading} bar v0.1.0 (registry file://[..])
{compiling} bar v0.1.0 (registry file://[..])
-{compiling} a v0.0.1 ({dir})
+{compiling} a v0.0.1 ({dir}/a)
{compiling} foo v0.0.1 ({dir})
", updating = UPDATING, downloading = DOWNLOADING, compiling = COMPILING,
dir = p.url())));
assert_that(p.cargo_process("run").arg("-v").arg("--release").arg("--example").arg("a"),
execs().with_status(0).with_stdout(&format!("\
-{compiling} bar v0.0.1 ({url})
+{compiling} bar v0.0.1 ({url}/bar)
{running} `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
-C opt-level=3 \
-C metadata=[..] \
assert_that(p.cargo("run").arg("-v").arg("--example").arg("a"),
execs().with_status(0).with_stdout(&format!("\
-{compiling} bar v0.0.1 ({url})
+{compiling} bar v0.0.1 ({url}/bar)
{running} `rustc bar{sep}src{sep}bar.rs --crate-name bar --crate-type lib \
-g \
-C metadata=[..] \
execs()
.with_status(0)
.with_stdout(format!("\
-{compiling} bar v0.1.0 ({url})
+{compiling} bar v0.1.0 ([..])
{running} `[..] -g -C [..]`
{compiling} foo v0.0.1 ({url})
{running} `[..] -g -Z unstable-options [..]`
execs()
.with_status(0)
.with_stdout(format!("\
-{compiling} bar v0.1.0 ({url})
+{compiling} bar v0.1.0 ([..])
{running} `[..]--crate-name bar --crate-type lib [..] -Z unstable-options [..]`
",
- compiling = COMPILING, running = RUNNING,
- url = foo.url())));
+ compiling = COMPILING, running = RUNNING)));
});
test!(fail_with_multiple_packages {
execs()
.with_status(0)
.with_stdout(format!("\
-{compiling} bar v0.0.1 ({url})
-{running} `rustc {bar_dir}{sep}src{sep}lib.rs [..]`
+{compiling} bar v0.0.1 ([..])
+{running} `rustc [..]bar{sep}src{sep}lib.rs [..]`
{documenting} foo v0.0.1 ({url})
{running} `rustdoc src{sep}lib.rs --crate-name foo \
-o {dir}{sep}target{sep}doc \
",
running = RUNNING, compiling = COMPILING, sep = SEP,
documenting = DOCUMENTING,
- dir = foo.root().display(), url = foo.url(),
- bar_dir = bar.root().display())));
+ dir = foo.root().display(), url = foo.url())));
});
test!(rustdoc_only_bar_dependency {
execs()
.with_status(0)
.with_stdout(format!("\
-{documenting} bar v0.0.1 ({url})
-{running} `rustdoc {bar_dir}{sep}src{sep}lib.rs --crate-name bar \
+{documenting} bar v0.0.1 ([..])
+{running} `rustdoc [..]bar{sep}src{sep}lib.rs --crate-name bar \
-o {dir}{sep}target{sep}doc \
--no-defaults \
-L dependency={dir}{sep}target{sep}debug{sep}deps \
-L dependency={dir}{sep}target{sep}debug{sep}deps`
",
running = RUNNING, documenting = DOCUMENTING, sep = SEP,
- dir = foo.root().display(), url = foo.url(),
- bar_dir = bar.root().display())));
+ dir = foo.root().display())));
});
assert_that(p.cargo_process("test").arg("-v").arg("--release"),
execs().with_stdout(format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
{running} [..] -C opt-level=3 [..]
{compiling} foo v0.1.0 ({dir})
{running} [..] -C opt-level=3 [..]
assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} foo v0.0.1 ({dir})
+{compiling} foo v0.0.1 ([..])
{compiling} bar v0.0.1 ({dir})
{running} target[..]
assert_that(p.cargo_process("test"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} bar v0.0.1 ({dir})
+{compiling} bar v0.0.1 ({dir}/bar)
{compiling} foo v0.0.1 ({dir})
{running} target[..]foo-[..]
assert_that(p.cargo("test").arg("-p").arg("d1"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} d1 v0.0.1 ({dir})
+{compiling} d1 v0.0.1 ({dir}/d1)
{running} target[..]d1-[..]
running 0 tests
assert_that(p.cargo("test").arg("-p").arg("d2"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} d2 v0.0.1 ({dir})
+{compiling} d2 v0.0.1 ({dir}/d2)
{running} target[..]d2-[..]
running 0 tests
assert_that(p.cargo("test").arg("-p").arg("d1"),
execs().with_status(0)
.with_stdout(&format!("\
-{compiling} d1 v0.0.1 ({dir})
+{compiling} d1 v0.0.1 ({dir}/d1)
{running} target[..]deps[..]d1[..]
running 0 tests