Remove is_build: Cell<bool> from ProjectBuilder and introduce a new type Project.
is_build==false <-> ProjectBuilder
is_build==true <-> Project
Also add #[must_use] to ProjectBuilder to confirm its instances are surely consumed by its build() method to produce Project.
The same goes for RepoBuilder.
ProjectBuilder::cargo_process() was removed as its design heavily depended on the internal mutability.
Signed-off-by: NODA, Kai <nodakai@gmail.com>
#[test]
fn bad1() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
.file(".cargo/config", r#"
[target]
nonexistent-target = "foo"
- "#);
- assert_that(foo.cargo_process("build").arg("-v")
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v")
.arg("--target=nonexistent-target"),
execs().with_status(101).with_stderr("\
[ERROR] expected table for configuration key `target.nonexistent-target`, \
#[test]
fn bad2() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
.file(".cargo/config", r#"
[http]
proxy = 3.0
- "#);
- assert_that(foo.cargo_process("publish").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("publish").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] Couldn't load Cargo configuration
#[test]
fn bad3() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
.file(".cargo/config", r#"
[http]
proxy = true
- "#);
+ "#)
+ .build();
Package::new("foo", "1.0.0").publish();
- assert_that(foo.cargo_process("publish").arg("-v"),
+ assert_that(p.cargo("publish").arg("-v"),
execs().with_status(101).with_stderr("\
error: failed to update registry [..]
#[test]
fn bad4() {
- let foo = project("foo")
+ let p = project("foo")
.file(".cargo/config", r#"
[cargo-new]
name = false
- "#);
- assert_that(foo.cargo_process("new").arg("-v").arg("foo"),
+ "#)
+ .build();
+ assert_that(p.cargo("new").arg("-v").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] Failed to create project `foo` at `[..]`
#[test]
fn bad5() {
- let foo = project("foo")
+ let p = project("foo")
.file(".cargo/config", r#"
foo = ""
"#)
.file("foo/.cargo/config", r#"
foo = 2
- "#);
- foo.build();
- assert_that(foo.cargo("new")
- .arg("-v").arg("foo").cwd(&foo.root().join("foo")),
+ "#)
+ .build();
+ assert_that(p.cargo("new")
+ .arg("-v").arg("foo").cwd(&p.root().join("foo")),
execs().with_status(101).with_stderr("\
[ERROR] Failed to create project `foo` at `[..]`
#[test]
fn bad_cargo_config_jobs() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
- "#)
- .file("src/lib.rs", "")
- .file(".cargo/config", r#"
- [build]
- jobs = -1
- "#);
- assert_that(foo.cargo_process("build").arg("-v"),
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [build]
+ jobs = -1
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] build.jobs must be positive, but found -1 in [..]
"));
#[test]
fn default_cargo_config_jobs() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
- "#)
- .file("src/lib.rs", "")
- .file(".cargo/config", r#"
- [build]
- jobs = 1
- "#);
- assert_that(foo.cargo_process("build").arg("-v"),
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [build]
+ jobs = 1
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
#[test]
fn good_cargo_config_jobs() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
- "#)
- .file("src/lib.rs", "")
- .file(".cargo/config", r#"
- [build]
- jobs = 4
- "#);
- assert_that(foo.cargo_process("build").arg("-v"),
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ [build]
+ jobs = 4
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
#[test]
fn invalid_global_config() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
- [dependencies]
- foo = "0.1.0"
- "#)
- .file(".cargo/config", "4")
- .file("src/lib.rs", "");
+ [dependencies]
+ foo = "0.1.0"
+ "#)
+ .file(".cargo/config", "4")
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] Couldn't load Cargo configuration
#[test]
fn bad_cargo_lock() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
- "#)
- .file("Cargo.lock", "[[package]]\nfoo = 92")
- .file("src/lib.rs", "");
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file("Cargo.lock", "[[package]]\nfoo = 92")
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse lock file at: [..]Cargo.lock
name = "foo"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").arg("--verbose"),
execs().with_status(101).with_stderr("\
name = "foo"
version = "0.1.0"
source = "You shall not parse"
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").arg("--verbose"),
execs().with_status(101).with_stderr("\
dependencies = [
"bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").arg("--verbose"),
execs().with_status(101).with_stderr("\
#[test]
fn bad_git_dependency() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
- [dependencies]
- foo = { git = "file:.." }
- "#)
- .file("src/lib.rs", "");
+ [dependencies]
+ foo = { git = "file:.." }
+ "#)
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[UPDATING] git repository `file:///`
[ERROR] failed to load source for a dependency on `foo`
#[test]
fn bad_crate_type() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
- [lib]
- crate-type = ["bad_type", "rlib"]
- "#)
- .file("src/lib.rs", "");
+ [lib]
+ crate-type = ["bad_type", "rlib"]
+ "#)
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr_contains("\
error: failed to run `rustc` to learn about target-specific information
"));
#[test]
fn malformed_override() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
- [target.x86_64-apple-darwin.freetype]
- native = {
- foo: "bar"
- }
- "#)
- .file("src/lib.rs", "");
+ [target.x86_64-apple-darwin.freetype]
+ native = {
+ foo: "bar"
+ }
+ "#)
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn duplicate_binary_names() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "qqq"
- version = "0.1.0"
- authors = ["A <a@a.a>"]
-
- [[bin]]
- name = "e"
- path = "a.rs"
-
- [[bin]]
- name = "e"
- path = "b.rs"
- "#)
- .file("a.rs", r#"fn main() -> () {}"#)
- .file("b.rs", r#"fn main() -> () {}"#);
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "qqq"
+ version = "0.1.0"
+ authors = ["A <a@a.a>"]
+
+ [[bin]]
+ name = "e"
+ path = "a.rs"
- assert_that(foo.cargo_process("build"),
+ [[bin]]
+ name = "e"
+ path = "b.rs"
+ "#)
+ .file("a.rs", r#"fn main() -> () {}"#)
+ .file("b.rs", r#"fn main() -> () {}"#)
+ .build();
+
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn duplicate_example_names() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "qqq"
- version = "0.1.0"
- authors = ["A <a@a.a>"]
-
- [[example]]
- name = "ex"
- path = "examples/ex.rs"
-
- [[example]]
- name = "ex"
- path = "examples/ex2.rs"
- "#)
- .file("examples/ex.rs", r#"fn main () -> () {}"#)
- .file("examples/ex2.rs", r#"fn main () -> () {}"#);
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "qqq"
+ version = "0.1.0"
+ authors = ["A <a@a.a>"]
- assert_that(foo.cargo_process("build").arg("--example").arg("ex"),
+ [[example]]
+ name = "ex"
+ path = "examples/ex.rs"
+
+ [[example]]
+ name = "ex"
+ path = "examples/ex2.rs"
+ "#)
+ .file("examples/ex.rs", r#"fn main () -> () {}"#)
+ .file("examples/ex2.rs", r#"fn main () -> () {}"#)
+ .build();
+
+ assert_that(p.cargo("build").arg("--example").arg("ex"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn duplicate_bench_names() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "qqq"
- version = "0.1.0"
- authors = ["A <a@a.a>"]
-
- [[bench]]
- name = "ex"
- path = "benches/ex.rs"
-
- [[bench]]
- name = "ex"
- path = "benches/ex2.rs"
- "#)
- .file("benches/ex.rs", r#"fn main () {}"#)
- .file("benches/ex2.rs", r#"fn main () {}"#);
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "qqq"
+ version = "0.1.0"
+ authors = ["A <a@a.a>"]
+
+ [[bench]]
+ name = "ex"
+ path = "benches/ex.rs"
+
+ [[bench]]
+ name = "ex"
+ path = "benches/ex2.rs"
+ "#)
+ .file("benches/ex.rs", r#"fn main () {}"#)
+ .file("benches/ex2.rs", r#"fn main () {}"#)
+ .build();
- assert_that(foo.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn duplicate_deps() {
- let foo = project("foo")
- .file("shim-bar/Cargo.toml", r#"
- [package]
- name = "bar"
- version = "0.0.1"
- authors = []
- "#)
- .file("shim-bar/src/lib.rs", r#"
- pub fn a() {}
- "#)
- .file("linux-bar/Cargo.toml", r#"
- [package]
- name = "bar"
- version = "0.0.1"
- authors = []
- "#)
- .file("linux-bar/src/lib.rs", r#"
- pub fn a() {}
- "#)
- .file("Cargo.toml", r#"
- [package]
- name = "qqq"
- version = "0.0.1"
- authors = []
+ let p = project("foo")
+ .file("shim-bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("shim-bar/src/lib.rs", r#"
+ pub fn a() {}
+ "#)
+ .file("linux-bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("linux-bar/src/lib.rs", r#"
+ pub fn a() {}
+ "#)
+ .file("Cargo.toml", r#"
+ [package]
+ name = "qqq"
+ version = "0.0.1"
+ authors = []
- [dependencies]
- bar = { path = "shim-bar" }
+ [dependencies]
+ bar = { path = "shim-bar" }
- [target.x86_64-unknown-linux-gnu.dependencies]
- bar = { path = "linux-bar" }
- "#)
- .file("src/main.rs", r#"fn main () {}"#);
+ [target.x86_64-unknown-linux-gnu.dependencies]
+ bar = { path = "linux-bar" }
+ "#)
+ .file("src/main.rs", r#"fn main () {}"#)
+ .build();
- assert_that(foo.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn duplicate_deps_diff_sources() {
- let foo = project("foo")
- .file("shim-bar/Cargo.toml", r#"
- [package]
- name = "bar"
- version = "0.0.1"
- authors = []
- "#)
- .file("shim-bar/src/lib.rs", r#"
- pub fn a() {}
- "#)
- .file("linux-bar/Cargo.toml", r#"
- [package]
- name = "bar"
- version = "0.0.1"
- authors = []
- "#)
- .file("linux-bar/src/lib.rs", r#"
- pub fn a() {}
- "#)
- .file("Cargo.toml", r#"
- [package]
- name = "qqq"
- version = "0.0.1"
- authors = []
+ let p = project("foo")
+ .file("shim-bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("shim-bar/src/lib.rs", r#"
+ pub fn a() {}
+ "#)
+ .file("linux-bar/Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("linux-bar/src/lib.rs", r#"
+ pub fn a() {}
+ "#)
+ .file("Cargo.toml", r#"
+ [package]
+ name = "qqq"
+ version = "0.0.1"
+ authors = []
- [target.i686-unknown-linux-gnu.dependencies]
- bar = { path = "shim-bar" }
+ [target.i686-unknown-linux-gnu.dependencies]
+ bar = { path = "shim-bar" }
- [target.x86_64-unknown-linux-gnu.dependencies]
- bar = { path = "linux-bar" }
- "#)
- .file("src/main.rs", r#"fn main () {}"#);
+ [target.x86_64-unknown-linux-gnu.dependencies]
+ bar = { path = "linux-bar" }
+ "#)
+ .file("src/main.rs", r#"fn main () {}"#)
+ .build();
- assert_that(foo.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[target.foo]
bar = "3"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
warning: unused manifest key: target.foo.bar
[COMPILING] foo v0.1.0 (file:///[..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"));
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#)
.file("src/lib.rs", r#"
pub fn foo() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
warning: unused manifest key: project.bulid
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"));
- let mut p = project("bar");
- p = p
+ let p = project("bar")
.file("Cargo.toml", r#"
[project]
"#)
.file("src/lib.rs", r#"
pub fn foo() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
warning: unused manifest key: lib.build
#[test]
fn empty_dependencies() {
let p = project("empty_deps")
- .file("Cargo.toml", r#"
- [package]
- name = "empty_deps"
- version = "0.0.0"
- authors = []
+ .file("Cargo.toml", r#"
+ [package]
+ name = "empty_deps"
+ version = "0.0.0"
+ authors = []
- [dependencies]
- foo = {}
- "#)
- .file("src/main.rs", "fn main() {}");
+ [dependencies]
+ foo = {}
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "0.0.1").publish();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr_contains("\
warning: dependency (foo) specified without providing a local path, Git repository, or version \
to use. This will be considered an error in future versions
#[test]
fn invalid_toml_historically_allowed_is_warned() {
let p = project("empty_deps")
- .file("Cargo.toml", r#"
- [package]
- name = "empty_deps"
- version = "0.0.0"
- authors = []
- "#)
- .file(".cargo/config", r#"
- [foo] bar = 2
- "#)
- .file("src/main.rs", "fn main() {}");
+ .file("Cargo.toml", r#"
+ [package]
+ name = "empty_deps"
+ version = "0.0.0"
+ authors = []
+ "#)
+ .file(".cargo/config", r#"
+ [foo] bar = 2
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
warning: TOML file found which contains invalid syntax and will soon not parse
at `[..]config`.
#[test]
fn ambiguous_git_reference() {
- let foo = project("foo")
- .file("Cargo.toml", r#"
- [package]
- name = "foo"
- version = "0.0.0"
- authors = []
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.0"
+ authors = []
- [dependencies.bar]
- git = "https://127.0.0.1"
- branch = "master"
- tag = "some-tag"
- "#)
- .file("src/lib.rs", "");
+ [dependencies.bar]
+ git = "https://127.0.0.1"
+ branch = "master"
+ tag = "some-tag"
+ "#)
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_stderr_contains("\
[WARNING] dependency (bar) specification is ambiguous. \
Only one of `branch`, `tag` or `rev` is allowed. \
.file("src/lib.rs", "")
.file(".cargo/config", r#"
[source.foo]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: no source URL specified for `source.foo`, need [..]
"));
[source.crates-io]
registry = 'http://example.com'
replace-with = 'bar'
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to load source for a dependency on `bar`
[source.crates-io]
registry = 'http://example.com'
replace-with = 'crates-io'
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to load source for a dependency on `bar`
[source.bar]
registry = 'http://example.com'
replace-with = 'crates-io'
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to load source for a dependency on `bar`
[source.bar]
registry = 'not a url'
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: configuration key `source.bar.registry` specified an invalid URL (in [..])
git = "https://127.0.0.1"
path = "bar"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(foo.cargo("build").arg("-v"),
execs().with_stderr_contains("\
[WARNING] dependency (bar) specification is ambiguous. \
Only one of `git` or `path` is allowed. \
[source.crates-io]
registry = 'http://example.com'
replace-with = ['not', 'a', 'string']
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: expected a string, but found a array for `source.crates-io.replace-with` in [..]
"));
path = "bar"
branch = "spam"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(foo.cargo("build").arg("-v"),
execs().with_stderr_contains("\
[WARNING] key `branch` is ignored for dependency (bar). \
This will be considered an error in future versions"));
[source.foo]
registry = 'http://example.com'
local-registry = 'file:///another/file'
- "#);
+ "#)
+ .build();
Package::new("bar", "0.1.0").publish();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: more than one source URL specified for `source.foo`
"));
[dependencies]
bar = 3
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
[profile.dev]
debug = 'a'
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
authors = []
build = 3
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process(command)
+ assert_that(p.cargo(command)
.arg("--manifest-path").arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) {
- let p = project("foo");
+ let p = project("foo").build();
let expected_path = manifest_path_argument
.split('/').collect::<Vec<_>>().join("[..]");
- assert_that(p.cargo_process(command)
+ assert_that(p.cargo(command)
.arg("--manifest-path").arg(manifest_path_argument)
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn verify_project_dir_containing_cargo_toml() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg("foo")
.cwd(p.root().parent().unwrap()),
execs().with_status(1)
fn verify_project_dir_plus_file() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg("foo/bar")
.cwd(p.root().parent().unwrap()),
execs().with_status(1)
fn verify_project_dir_plus_path() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg("foo/bar/baz")
.cwd(p.root().parent().unwrap()),
execs().with_status(1)
#[test]
fn verify_project_dir_to_nonexistent_cargo_toml() {
- let p = project("foo");
- assert_that(p.cargo_process("verify-project")
+ let p = project("foo").build();
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg("foo/bar/baz/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(1)
#[bench]
fn bench_hello(_b: &mut test::Bencher) {
assert_eq!(hello(), "hello")
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build"), execs());
+ assert_that(p.cargo("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
fn bench_bench_implicit() {
if !is_nightly() { return }
- let prj = project("foo")
+ let p = project("foo")
.file("Cargo.toml" , r#"
[package]
name = "foo"
.file("benches/mybench.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run2(_ben: &mut test::Bencher) { }"#);
+ #[bench] fn run2(_ben: &mut test::Bencher) { }"#)
+ .build();
- assert_that(prj.cargo_process("bench").arg("--benches"),
+ assert_that(p.cargo("bench").arg("--benches"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[/]release[/]deps[/]mybench-[..][EXE]
-", dir = prj.url()))
+", dir = p.url()))
.with_stdout_contains("test run2 ... bench: [..]"));
}
fn bench_bin_implicit() {
if !is_nightly() { return }
- let prj = project("foo")
+ let p = project("foo")
.file("Cargo.toml" , r#"
[package]
name = "foo"
.file("benches/mybench.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run2(_ben: &mut test::Bencher) { }"#);
+ #[bench] fn run2(_ben: &mut test::Bencher) { }"#)
+ .build();
- assert_that(prj.cargo_process("bench").arg("--bins"),
+ assert_that(p.cargo("bench").arg("--bins"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]
-", dir = prj.url()))
+", dir = p.url()))
.with_stdout_contains("test run1 ... bench: [..]"));
}
fn bench_tarname() {
if !is_nightly() { return }
- let prj = project("foo")
+ let p = project("foo")
.file("Cargo.toml" , r#"
[package]
name = "foo"
.file("benches/bin2.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run2(_ben: &mut test::Bencher) { }"#);
+ #[bench] fn run2(_ben: &mut test::Bencher) { }"#)
+ .build();
- assert_that(prj.cargo_process("bench").arg("--bench").arg("bin2"),
+ assert_that(p.cargo("bench").arg("--bench").arg("bin2"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] target[/]release[/]deps[/]bin2-[..][EXE]
-", dir = prj.url()))
+", dir = p.url()))
.with_stdout_contains("test run2 ... bench: [..]"));
}
fn bench_multiple_targets() {
if !is_nightly() { return }
- let prj = project("foo")
+ let p = project("foo")
.file("Cargo.toml" , r#"
[package]
name = "foo"
.file("benches/bin3.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run3(_ben: &mut test::Bencher) { }"#);
+ #[bench] fn run3(_ben: &mut test::Bencher) { }"#)
+ .build();
- assert_that(prj.cargo_process("bench")
+ assert_that(p.cargo("bench")
.arg("--bench").arg("bin1")
.arg("--bench").arg("bin2"),
execs()
extern crate test;
fn main() {}
#[bench] fn bench_hello(_b: &mut test::Bencher) {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench").arg("-v").arg("hello"),
+ assert_that(p.cargo("bench").arg("-v").arg("hello"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.5.0 ({url})
[RUNNING] `rustc [..] src[/]main.rs [..]`
extern crate foo;
extern crate test;
#[bench] fn bench_bench(_b: &mut test::Bencher) { foo::foo() }
- "#);
+ "#)
+ .build();
- let output = p.cargo_process("bench").exec_with_output().unwrap();
+ let output = p.cargo("bench").exec_with_output().unwrap();
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("test bin_bench"), "bin_bench missing\n{}", output);
assert!(output.contains("test lib_bench"), "lib_bench missing\n{}", output);
#[bench]
fn bench_hello(_b: &mut test::Bencher) {
assert_eq!(hello(), "nope")
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build"), execs());
+ assert_that(p.cargo("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
#[bench]
fn bin_bench(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
fn bar_bench(_b: &mut test::Bencher) {
foo::foo();
}
- ");
- let p2 = project("foo")
+ ")
+ .build();
+ let _p2 = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
#[bench]
fn foo_bench(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- p2.build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ([..])
#[bench]
fn external_bench(_b: &mut test::Bencher) {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
#[bench]
fn external_bench(_b: &mut test::Bencher) {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
.file("src/lib.rs", r"")
.file("examples/dont-run-me-i-will-fail.rs", r#"
fn main() { panic!("Examples should not be run by 'cargo test'"); }
- "#);
- assert_that(p.cargo_process("bench"),
+ "#)
+ .build();
+ assert_that(p.cargo("bench"),
execs().with_status(0));
}
#[bench] fn foo(_b: &mut test::Bencher) {}
#[bench] fn bar(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench").arg("bar"),
+ assert_that(p.cargo("bench").arg("bar"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
#[bench]
fn dummy_bench(b: &mut test::Bencher) { }
- "#);
+ "#)
+ .build();
- p.cargo_process("build");
+ p.cargo("build");
for _ in 0..2 {
assert_that(p.cargo("bench"),
#[bench]
fn bin_bench(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] release [optimized] target(s) in [..]
#[bench]
fn bench(_b: &mut test::Bencher) { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
#[bench]
fn bench(_b: &mut test::Bencher) { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
"#)
.file("bar/src/lib.rs", "
pub fn baz() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench").arg("-v"),
+ assert_that(p.cargo("bench").arg("-v"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
extern crate test;
#[bench]
fn foo(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
println!("example1");
testbench::f1();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench").arg("-v"),
+ assert_that(p.cargo("bench").arg("-v"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] testbench v6.6.6 ({url})
.file("benches/b.rs", r#"
#[test]
fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.1.0 ([..])
#[bench]
fn bench_baz(_: &mut Bencher) {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench").arg("--no-run"),
+ assert_that(p.cargo("bench").arg("--no-run"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.1.0 ([..])
#[bench]
fn bench_nope(_b: &mut test::Bencher) {
assert_eq!("nope", hello())
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("bench").arg("--no-fail-fast"),
+ assert_that(p.cargo("bench").arg("--no-fail-fast"),
execs().with_status(101)
.with_stderr_contains("\
[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
[dependencies.baz]
path = "../baz"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- let bar = project("bar")
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[project]
name = "bar"
#[bench]
fn bench_bar(_b: &mut Bencher) {}
- "#);
- bar.build();
+ "#)
+ .build();
- let baz = project("baz")
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[project]
name = "baz"
#[bench]
fn bench_baz(_b: &mut Bencher) {}
- "#);
- baz.build();
+ "#)
+ .build();
- assert_that(p.cargo_process("bench").arg("-p").arg("bar").arg("-p").arg("baz"),
+ assert_that(p.cargo("bench").arg("-p").arg("bar").arg("-p").arg("baz"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] target[/]release[/]deps[/]bbaz-[..][EXE]")
#[bench]
fn bench_bar(_: &mut Bencher) -> () { () }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench")
+ assert_that(p.cargo("bench")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("\
pub fn baz() {
break_the_build();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench")
+ assert_that(p.cargo("bench")
.arg("--all")
.arg("--exclude")
.arg("baz"),
#[bench]
fn bench_bar(_: &mut Bencher) -> () { () }
- "#);
+ "#)
+ .build();
// The order in which foo and bar are built is not guaranteed
- assert_that(p.cargo_process("bench")
+ assert_that(p.cargo("bench")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("\
#[bench]
fn bench_foo(_: &mut Bencher) -> () { () }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("bench"), execs().with_status(0).with_stderr_contains("\
+ assert_that(p.cargo("bench"), execs().with_status(0).with_stderr_contains("\
[WARNING] path `[..]src[/]bench.rs` was erroneously implicitly accepted for benchmark `bench`,
please set bench.path in Cargo.toml"));
}
use test::Bencher;
#[bench]
fn bench_bar(_: &mut Bencher) -> () { () }
- "#);
+ "#)
+ .build();
// The order in which foo and bar are built is not guaranteed
- assert_that(p.cargo_process("bench"),
+ assert_that(p.cargo("bench"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] target[/]release[/]deps[/]bar-[..][EXE]")
println!("username=foo");
println!("password=bar");
}
- "#);
+ "#)
+ .build();
- assert_that(script.cargo_process("build").arg("-v"),
+ assert_that(script.cargo("build").arg("-v"),
execs().with_status(0));
let script = script.bin("script");
.file(".cargo/config","\
[net]
retry = 0
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr(&format!("\
[UPDATING] git repository `http://{addr}/foo/bar`
[ERROR] failed to load source for a dependency on `bar`
.file(".cargo/config","\
[net]
retry = 0
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr_contains(&format!("\
[UPDATING] git repository `https://{addr}/foo/bar`
", addr = addr))
[dependencies.bar]
git = "ssh://127.0.0.1:{}/foo/bar"
"#, addr.port()))
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr_contains(&format!("\
[UPDATING] git repository `ssh://{addr}/foo/bar`
", addr = addr))
extern crate cargotest;
extern crate hamcrest;
-use cargotest::support::{basic_bin_manifest, execs, project, ProjectBuilder};
+use cargotest::support::{basic_bin_manifest, execs, project, Project};
use hamcrest::{assert_that};
-fn verbose_output_for_lib(p: &ProjectBuilder) -> String {
+fn verbose_output_for_lib(p: &Project) -> String {
format!("\
[COMPILING] {name} v{version} ({url})
[RUNNING] `rustc --crate-name {name} src[/]lib.rs --crate-type lib \
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--lib").arg("-v"),
+ assert_that(p.cargo("build").arg("--lib").arg("-v"),
execs()
.with_status(0)
.with_stderr(verbose_output_for_lib(&p)));
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/main.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--lib"),
+ assert_that(p.cargo("build").arg("--lib"),
execs().with_status(101)
.with_stderr("[ERROR] no library targets found"));
}
name = "test-dependency"
version = "0.0.1"
authors = ["wycats@example.com"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").env("CARGO_HOME", "./cargo_home/"),
+ assert_that(p.cargo("build").env("CARGO_HOME", "./cargo_home/"),
execs()
.with_status(0));
}
fn main() {
println!("cargo:rerun-if-env-changed=FOO");
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0)
println!("cargo:rerun-if-changed=foo");
}
"#)
- .file("foo", "");
- p.build();
+ .file("foo", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0)
fn main() {
std::process::exit(101);
}
- "#);
- assert_that(p.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr(&format!("\
[COMPILING] foo v0.5.0 ({url})
"#,
p.root().join("target").join("debug").join("build").display());
- let p = p.file("bar/build.rs", &file_content);
+ let p = p.file("bar/build.rs", &file_content).build();
-
- assert_that(p.cargo_process("build").arg("--features").arg("bar_feat"),
+ assert_that(p.cargo("build").arg("--features").arg("bar_feat"),
execs().with_status(0));
}
fn main() {
println!("cargo:rustc-flags=-aaa -bbb");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr_contains(&format!("\
[ERROR] Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ({})`: \
fn main() {
println!("cargo:rustc-flags=-l nonexistinglib -L /dummy/path1 -L /dummy/path2");
}
- "#);
+ "#)
+ .build();
// TODO: TEST FAILS BECAUSE OF WRONG STDOUT (but otherwise, the build works)
- assert_that(p.cargo_process("build").arg("--verbose"),
+ assert_that(p.cargo("build").arg("--verbose"),
execs().with_status(101)
.with_stderr(&format!("\
[COMPILING] bar v0.5.0 ({url})
authors = []
links = "a"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] package `foo v0.5.0 (file://[..])` specifies that it links to `a` but does \
build = "build.rs"
"#)
.file("a-sys/src/lib.rs", "")
- .file("a-sys/build.rs", "");
+ .file("a-sys/build.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] Multiple packages link to native library `a`. A native library can be \
build = "build.rs"
"#)
.file("a/a-sys/src/lib.rs", "")
- .file("a/a-sys/build.rs", "");
+ .file("a/a-sys/build.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] Multiple packages link to native library `a`. A native library can be \
build = "build.rs"
"#)
.file("a/src/lib.rs", "")
- .file("a/build.rs", "not valid rust code");
+ .file("a/build.rs", "not valid rust code")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[..]
rustc-flags = "-L foo -L bar"
foo = "bar"
bar = "baz"
- "#, target));
+ "#, target))
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
println!("cargo:foo=bar");
println!("cargo:bar=baz");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
.file("src/lib.rs", "")
.file("build.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
p.root().move_into_the_past();
println!("cargo:bar=baz");
std::thread::sleep(Duration::from_millis(500));
}
- "#);
- a.build();
+ "#)
+ .build();
a.root().move_into_the_past();
let p = project("foo")
assert_eq!(env::var("DEP_FOO_FOO").unwrap(), "bar");
assert_eq!(env::var("DEP_FOO_BAR").unwrap(), "baz");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
p.root().move_into_the_past();
.file("src/lib.rs", "")
.file("build.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
println!("build");
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
p.root().move_into_the_past();
.file(".cargo/config", &format!(r#"
[target.{}.foo]
rustc-flags = "-L foo"
- "#, target));
+ "#, target))
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("-j1"),
+ assert_that(p.cargo("build").arg("-v").arg("-j1"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]`
.file(".cargo/config", &format!(r#"
[target.{}.foo]
rustc-link-search = ["foo"]
- "#, target));
+ "#, target))
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("-j1"),
+ assert_that(p.cargo("build").arg("-v").arg("-j1"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustc --crate-name a [..] -L bar[..]-L foo[..]`
version = "0.5.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[COMPILING] a v0.5.0 (file://[..])
version = "0.5.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
+ assert_that(p.cargo("build").arg("-v").arg("--target").arg(&target),
execs().with_status(101)
.with_stderr_contains("\
[..]can't find crate for `aaaaa`[..]
version = "0.5.0"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[COMPILING] b v0.5.0 (file://[..])
let out = env::var("OUT_DIR").unwrap();
File::create(Path::new(&out).join("foo")).unwrap();
}
- "#);
+ "#)
+ .build();
// Make the file
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
p.root().move_into_the_past();
println!("cargo:rustc-flags=-L foo");
println!("cargo:rustc-flags=-l static=foo");
}
- "#);
- assert_that(p.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr_contains("\
[COMPILING] foo v0.5.0 (file://[..])
println!("cargo:rustc-link-search=foo");
println!("cargo:rustc-link-lib=static=foo");
}
- "#);
- assert_that(p.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr_contains("\
[COMPILING] foo v0.5.0 (file://[..])
}
").unwrap();
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("run"),
execs().with_status(0)
.file("src/lib.rs", "")
.file("build.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0));
}
authors = []
build = "build.rs"
"#)
- .file("build.rs", r#"fn main() {}"#);
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("build.rs", r#"fn main() {}"#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[dependencies.a]
path = "../a"
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
[dependencies.a]
path = "../a"
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
fn foo() -> i32 { 1 }
").unwrap();
}
- "#);
- assert_that(p.cargo_process("test"),
+ "#)
+ .build();
+ assert_that(p.cargo("test"),
execs().with_status(0));
}
build = "build.rs"
"#)
.file("a/build.rs", "fn main() {}")
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("test"), execs().with_status(0));
+ assert_that(p.cargo("test"), execs().with_status(0));
}
#[test]
fn build_script_with_dynamic_native_dependency() {
- let workspace = project("ws")
+ let _workspace = project("ws")
.file("Cargo.toml", r#"
[workspace]
members = ["builder", "foo"]
- "#);
- workspace.build();
+ "#)
+ .build();
let build = project("ws/builder")
.file("Cargo.toml", r#"
.file("src/lib.rs", r#"
#[no_mangle]
pub extern fn foo() {}
- "#);
- build.build();
+ "#)
+ .build();
let foo = project("ws/foo")
.file("Cargo.toml", r#"
extern { fn foo(); }
unsafe { foo() }
}
- "#);
- foo.build();
+ "#)
+ .build();
assert_that(build.cargo("build").arg("-v")
.env("RUST_LOG", "cargo::ops::cargo_rustc"),
assert_eq!(env::var("PROFILE").unwrap(), "release");
assert_eq!(env::var("DEBUG").unwrap(), "false");
}
- "#);
- assert_that(build.cargo_process("bench"),
+ "#)
+ .build();
+ assert_that(build.cargo("bench"),
execs().with_status(0));
}
.file("build.rs", r#"
fn main() {
}
- "#);
- assert_that(build.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(build.cargo("build"),
execs().with_status(0));
}
version = "0.1.0"
authors = []
"#)
- .file("bar/src/lib.rs", "pub fn do_nothing() {}");
+ .file("bar/src/lib.rs", "pub fn do_nothing() {}")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
}
#[test]
fn main() {
println!("cargo:rustc-cfg=foo");
}
- "#);
- assert_that(build.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(build.cargo("build").arg("-v"),
execs().with_status(0));
}
.file(".cargo/config", &format!(r#"
[target.{}.a]
rustc-cfg = ["foo"]
- "#, target));
+ "#, target))
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
#[cfg(foo)]
#[test]
fn test_bar() {}
- "#);
- assert_that(p.cargo_process("test").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("test").arg("-v"),
execs().with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[RUNNING] [..] build.rs [..]
.file("bar/src/lib.rs", r#"
#[cfg(bar)]
pub fn bar() {}
- "#);
- assert_that(p.cargo_process("doc"),
+ "#)
+ .build();
+ assert_that(p.cargo("doc"),
execs().with_status(0));
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
#[cfg(foo)]
#[test]
fn test_bar() {}
- "#);
- assert_that(p.cargo_process("test").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("test").arg("-v"),
execs().with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[RUNNING] `[..]`
.file("bar/src/lib.rs", r#"
#[cfg(bar)]
pub fn bar() {}
- "#) ;
- assert_that(p.cargo_process("doc"),
+ "#)
+ .build();
+ assert_that(p.cargo("doc"),
execs().with_status(0));
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
fn main() {
println!("cargo:rustc-env=FOO=foo");
}
- "#);
- assert_that(p.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(p.cargo("run").arg("-v"),
execs().with_status(0).with_stdout("foo\n"));
fn test_foo() {
assert_eq!("foo", foo::FOO);
}
- "#);
- assert_that(p.cargo_process("test").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("test").arg("-v"),
execs().with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[RUNNING] [..] build.rs [..]
fn main() {
println!("cargo:rustc-env=FOO=foo");
}
- "#);
- assert_that(p.cargo_process("doc").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("doc").arg("-v"),
execs().with_status(0));
}
fn main() {
println!("cargo:rustc-link-search=test");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v").arg("--test=foo"),
+ assert_that(p.cargo("test").arg("-v").arg("--test=foo"),
execs().with_status(0)
.with_stderr("\
[COMPILING] a v0.5.0 ([..]
println!("cargo:rustc-link-search=native=test");
}
"#)
- .file("c/src/lib.rs", "");
+ .file("c/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] c v0.5.0 ([..]
[RUNNING] `rustc [..]`
fn main() {
println!("cargo:rustc-link-search=native=foo");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..]`
[target.{}.foo]
rustc-link-search = [\"native=foo\"]
", target))
- .file("build.rs", "");
+ .file("build.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..] -L native=foo`
rustc-link-search = [\"./b\"]
rustc-flags = \"-l z -L ./\"
", target))
- .file("build.rs", "");
+ .file("build.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..]`
d = \"\"
e = \"\"
", target))
- .file("build.rs", "");
+ .file("build.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.5.0 ([..]
[RUNNING] `rustc [..]`
println!("cargo:rerun-if-changed=foo");
println!("cargo:rerun-if-changed=bar");
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
fn main() {
println!("cargo:rustc-link-search=native=bar");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustdoc --test [..] --crate-name foo [..]-L native=bar[..]`
fn main() {
println!("cargo:rustc-link-search=native=bar");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustc [..] -L native=foo -L native=bar[..]`
.file("src/main.rs", r#"
#[cfg(foo)]
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
build = "build.rs"
"#)
.file("a/build.rs", "fn main() {}")
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
version = "0.5.0"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0));
}
println!("cargo:warning=foo");
println!("cargo:warning=bar");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.5.0 ([..])
[dependencies]
bar = "*"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
[dependencies]
bar = "*"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-vv"),
+ assert_that(p.cargo("build").arg("-vv"),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
std::io::stderr().write_all(b"stderr\n").unwrap();
std::io::stdout().write_all(b"stdout\n").unwrap();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-vv"),
+ assert_that(p.cargo("build").arg("-vv"),
execs().with_status(0)
.with_stdout("\
stdout
.file(".cargo/config", &format!(r#"
[target.{}.'a.b']
rustc-link-search = ["foo"]
- "#, target));
+ "#, target))
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustc --crate-name foo [..] [..] -L foo[..]`
#[test]
fn rustc_and_rustdoc_set_correctly() {
- let build = project("builder")
+ let p = project("builder")
.file("Cargo.toml", r#"
[package]
name = "builder"
assert_eq!(env::var("RUSTC").unwrap(), "rustc");
assert_eq!(env::var("RUSTDOC").unwrap(), "rustdoc");
}
- "#);
- assert_that(build.cargo_process("bench"),
+ "#)
+ .build();
+ assert_that(p.cargo("bench"),
execs().with_status(0));
}
#[test]
fn cfg_env_vars_available() {
- let build = project("builder")
+ let p = project("builder")
.file("Cargo.toml", r#"
[package]
name = "builder"
assert_eq!(fam, "windows");
}
}
- "#);
- assert_that(build.cargo_process("bench"),
+ "#)
+ .build();
+ assert_that(p.cargo("bench"),
execs().with_status(0));
}
#[test]
fn switch_features_rerun() {
- let build = project("builder")
+ let p = project("builder")
.file("Cargo.toml", r#"
[package]
name = "builder"
f.write_all(b"bar").unwrap();
}
}
- "#);
- build.build();
+ "#)
+ .build();
- assert_that(build.cargo("run").arg("-v").arg("--features=foo"),
+ assert_that(p.cargo("run").arg("-v").arg("--features=foo"),
execs().with_status(0).with_stdout("foo\n"));
- assert_that(build.cargo("run").arg("-v"),
+ assert_that(p.cargo("run").arg("-v"),
execs().with_status(0).with_stdout("bar\n"));
- assert_that(build.cargo("run").arg("-v").arg("--features=foo"),
+ assert_that(p.cargo("run").arg("-v").arg("--features=foo"),
execs().with_status(0).with_stdout("foo\n"));
}
fn main() {
println!("cargo:rustc-cfg=foo");
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("run").arg("-v"),
execs().with_status(0));
fn main() {
println!("cargo:rustc-cfg=foo");
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("run").arg("-v"),
execs().with_status(0));
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr_contains("\
[RUNNING] `rustc --crate-name foo [..] -L native=test1 -L native=test2 \
fn cargo_compile_simple() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
fn cargo_fail_with_no_stderr() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &String::from("refusal"));
- let p = p.build();
+ .file("src/foo.rs", &String::from("refusal"))
+ .build();
assert_that(p.cargo("build").arg("--message-format=json"), execs().with_status(101)
.with_stderr_does_not_contain("--- stderr"));
}
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
- p.build();
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
assert_that(
p.cargo("build").arg("-v").env("CARGO_INCREMENTAL", "1"),
fn cargo_compile_manifest_path() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--manifest-path").arg("foo/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(0));
#[test]
fn cargo_compile_with_invalid_manifest() {
let p = project("foo")
- .file("Cargo.toml", "");
+ .file("Cargo.toml", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
.file("Cargo.toml", r"
[project]
foo = bar
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
version = "0.0.1"
authors = []
"#)
- .file("src/Cargo.toml", "a = bar");
+ .file("src/Cargo.toml", "a = bar")
+ .build();
- assert_that(p.cargo_process("build").arg("--manifest-path")
+ assert_that(p.cargo("build").arg("--manifest-path")
.arg("src/Cargo.toml"),
execs()
.with_status(101)
.file("src/main.rs", r#"
#![allow(warnings)]
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(0)
.with_stderr("\
name = "foo"
authors = []
version = "1.0"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
name = ""
authors = []
version = "0.0.0"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
[[bin]]
name = ""
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
[[bin]]
name = "build"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
[lib]
name = ""
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr("\
#[test]
fn cargo_compile_without_manifest() {
let tmpdir = TempDir::new("cargo").unwrap();
- let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf());
+ let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf()).build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] could not find `Cargo.toml` in `[..]` or any parent directory
fn cargo_compile_with_invalid_code() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", "invalid rust code!");
+ .file("src/foo.rs", "invalid rust code!")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_status(101)
.with_stderr_contains("\
[dependencies.baz]
path = "../baz"
"#)
- .file("src/main.rs", "invalid rust code!");
- let bar = project("bar")
+ .file("src/main.rs", "invalid rust code!")
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", &basic_bin_manifest("bar"))
- .file("src/lib.rs", "invalid rust code!");
- let baz = project("baz")
+ .file("src/lib.rs", "invalid rust code!")
+ .build();
+ let _baz = project("baz")
.file("Cargo.toml", &basic_bin_manifest("baz"))
- .file("src/lib.rs", "invalid rust code!");
- bar.build();
- baz.build();
- assert_that(p.cargo_process("build"), execs().with_status(101));
+ .file("src/lib.rs", "invalid rust code!")
+ .build();
+ assert_that(p.cargo("build"), execs().with_status(101));
}
#[test]
fn cargo_compile_with_warnings_in_the_root_package() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", "fn main() {} fn dead() {}");
+ .file("src/foo.rs", "fn main() {} fn dead() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr_contains("\
[..]function is never used: `dead`[..]
"));
#[test]
fn cargo_compile_with_warnings_in_a_dep_package() {
- let mut p = project("foo");
-
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
}
fn dead() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr_contains("\
[..]function is never used: `dead`[..]
"));
pub fn gimme() -> String {
"test passed".to_string()
}
- "#);
+ "#)
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
pub fn gimme() -> String {
"test passed".to_string()
}
- "#);
+ "#)
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
pub fn gimme() -> String {
"test passed".to_string()
}
- "#);
+ "#)
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
pub fn gimme() -> String {
"test passed".to_string()
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"), execs());
+ assert_that(p.cargo("build"), execs());
assert_that(&p.bin("foo"), existing_file());
assert_that(&p.bin("libbar.rlib"), is_not(existing_file()));
"#)
.file("src/bin/foo.rs", &main_file(r#""i am foo""#, &["bar"]))
.file("bar/Cargo.toml", &basic_bin_manifest("bar"))
- .file("bar/src/bar.rs", &main_file(r#""i am bar""#, &[]));
+ .file("bar/src/bar.rs", &main_file(r#""i am bar""#, &[]))
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr(&format!(
r#"[ERROR] no matching package named `notquitebar` found (required by `foo`)
location searched: {proj_dir}/bar
"#)
.file("examples/a.rs", r#"
fn main() { println!("example"); }
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").arg("--bin").arg("bin.rs"),
execs().with_status(101).with_stderr("\
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
File::create(&p.root().join("bar/Cargo.toml")).unwrap().write_all(br#"
[package]
.file("src/main.rs", r#"
mod a; fn main() {}
"#)
- .file("src/a.rs", "");
+ .file("src/a.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
let lockfile = p.root().join("Cargo.lock");
name = "bar"
crate_type = ["dylib"]
"#)
- .file("bar/src/lib.rs", "// hello");
- p.build();
+ .file("bar/src/lib.rs", "// hello")
+ .build();
// No metadata on libbar since it's a dylib path dependency
assert_that(p.cargo("build").arg("-v"),
env!("CARGO_PKG_VERSION_PRE"),
env!("CARGO_MANIFEST_DIR"))
}
- "#);
+ "#)
+ .build();
println!("build");
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
println!("bin");
assert_that(process(&p.bin("foo")),
pub fn authors() -> String {
format!("{}", env!("CARGO_PKG_AUTHORS"))
}
- "#);
+ "#)
+ .build();
println!("build");
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
println!("bin");
assert_that(process(&p.bin("foo")),
// Regression test for #4277
#[test]
fn crate_library_path_env_var() {
- let mut p = project("foo");
-
- p = p.file("Cargo.toml", r#"
+ let p = project("foo")
+ .file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
let paths = std::env::split_paths(&search_path).collect::<Vec<_>>();
assert!(!paths.contains(&"".into()));
}}
- "##, dylib_path_envvar()));
+ "##, dylib_path_envvar()))
+ .build();
- assert_that(setenv_for_removing_empty_component(p.cargo_process("run")),
+ assert_that(setenv_for_removing_empty_component(p.cargo("run")),
execs().with_status(0));
}
fn main() {}
"#)
.file("src/lib.rs", r#" "#)
- .file("libc.so.6", r#""#);
+ .file("libc.so.6", r#""#)
+ .build();
- assert_that(setenv_for_removing_empty_component(p.cargo_process("build")),
+ assert_that(setenv_for_removing_empty_component(p.cargo("build")),
execs().with_status(0));
}
// this is testing that src/<pkg-name>.rs still works (for now)
#[test]
fn many_crate_types_old_style_lib_location() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#)
.file("src/foo.rs", r#"
pub fn foo() {}
- "#);
- assert_that(p.cargo_process("build"), execs().with_status(0).with_stderr_contains("\
+ "#)
+ .build();
+ assert_that(p.cargo("build"), execs().with_status(0).with_stderr_contains("\
[WARNING] path `[..]src[/]foo.rs` was erroneously implicitly accepted for library `foo`,
please rename the file to `src/lib.rs` or set lib.path in Cargo.toml"));
#[test]
fn many_crate_types_correct() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#)
.file("src/lib.rs", r#"
pub fn foo() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
#[test]
fn self_dependency() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "test"
path = "src/test.rs"
"#)
- .file("src/test.rs", "fn main() {}");
- assert_that(p.cargo_process("build"),
+ .file("src/test.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] cyclic package dependency: package `test v0.0.0 ([..])` depends on itself
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
- .symlink("Notafile", "bar");
+ .symlink("Notafile", "bar")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
#[test]
fn missing_lib_and_bin() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "test"
version = "0.0.0"
authors = []
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]Cargo.toml`
return
}
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
[profile.release]
lto = true
"#)
- .file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]main.rs --crate-type bin \
#[test]
fn verbose_build() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
version = "0.0.0"
authors = []
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
#[test]
fn verbose_release_build() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
version = "0.0.0"
authors = []
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
#[test]
fn verbose_release_build_deps() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
crate_type = ["dylib", "rlib"]
"#)
- .file("foo/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ .file("foo/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] foo v0.0.0 ({url}/foo)
[RUNNING] `rustc --crate-name foo foo[/]src[/]lib.rs \
#[test]
fn explicit_examples() {
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "world"
version = "1.0.0"
.file("examples/ex-goodbye.rs", r#"
extern crate world;
fn main() { println!("{}, {}!", world::get_goodbye(), world::get_world()); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v"), execs().with_status(0));
+ assert_that(p.cargo("test").arg("-v"), execs().with_status(0));
assert_that(process(&p.bin("examples/hello")),
execs().with_status(0).with_stdout("Hello, World!\n"));
assert_that(process(&p.bin("examples/goodbye")),
#[test]
fn non_existing_example() {
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "world"
version = "1.0.0"
name = "hello"
"#)
.file("src/lib.rs", "")
- .file("examples/ehlo.rs", "");
+ .file("examples/ehlo.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-v"), execs().with_status(101).with_stderr("\
+ assert_that(p.cargo("test").arg("-v"), execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
Caused by:
#[test]
fn non_existing_binary() {
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "world"
version = "1.0.0"
name = "hello"
"#)
.file("src/lib.rs", "")
- .file("src/bin/ehlo.rs", "");
+ .file("src/bin/ehlo.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(101).with_stderr("\
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
Caused by:
#[test]
fn legacy_binary_paths_warinigs() {
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "1.0.0"
name = "bar"
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
[WARNING] path `[..]src[/]main.rs` was erroneously implicitly accepted for binary `bar`,
please set bin.path in Cargo.toml"));
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "1.0.0"
name = "bar"
"#)
.file("src/lib.rs", "")
- .file("src/bin/main.rs", "fn main() {}");
+ .file("src/bin/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
[WARNING] path `[..]src[/]bin[/]main.rs` was erroneously implicitly accepted for binary `bar`,
please set bin.path in Cargo.toml"));
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "1.0.0"
[[bin]]
name = "bar"
"#)
- .file("src/bar.rs", "fn main() {}");
+ .file("src/bar.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0).with_stderr_contains("\
[WARNING] path `[..]src[/]bar.rs` was erroneously implicitly accepted for binary `bar`,
please set bin.path in Cargo.toml"));
}
#[test]
fn implicit_examples() {
- let mut p = project("world");
- p = p.file("Cargo.toml", r#"
+ let p = project("world")
+ .file("Cargo.toml", r#"
[package]
name = "world"
version = "1.0.0"
fn main() {
println!("{}, {}!", world::get_goodbye(), world::get_world());
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"), execs().with_status(0));
+ assert_that(p.cargo("test"), execs().with_status(0));
assert_that(process(&p.bin("examples/hello")),
execs().with_status(0).with_stdout("Hello, World!\n"));
assert_that(process(&p.bin("examples/goodbye")),
println!("fast")
}
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")),
execs().with_status(0).with_stdout("slow\n"));
}
println!("fast")
}
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--release"),
+ assert_that(p.cargo("build").arg("--release"),
execs().with_status(0));
assert_that(process(&p.release_bin("foo")),
execs().with_status(0).with_stdout("fast\n"));
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")), execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
- p.build();
+ .file("bar/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"), execs().with_status(0));
p.change_file("Cargo.toml", r#"
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("target/Cargo.toml", "bad-toml");
+ .file("target/Cargo.toml", "bad-toml")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(process(&p.bin("foo")), execs().with_status(0));
}
.file("src/main.rs", "
extern crate syntax;
fn main() { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
name = "foo"
crate-type = ["staticlib"]
"#)
- .file("src/lib.rs", "pub fn foo() {}");
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
// env var is a test for #1381
- assert_that(p.cargo_process("build").env("RUST_LOG", "nekoneko=trace"),
+ assert_that(p.cargo("build").env("RUST_LOG", "nekoneko=trace"),
execs().with_status(0));
}
fn main() {
foo::foo();
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
}
#[test]
version = "0.0.1"
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "bad syntax");
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ .file("src/main.rs", "bad syntax")
+ .build();
+ assert_that(p.cargo("build"), execs().with_status(0));
}
#[test]
name = "foo"
path = "src/bar.rs"
"#)
- .file("src/bar.rs", "");
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ .file("src/bar.rs", "")
+ .build();
+ assert_that(p.cargo("build"), execs().with_status(0));
}
#[test]
exclude = ["src/b*.rs"]
"#)
.file("build.rs", "fn main() {}")
- .file("src/lib.rs", "pub fn bar() -> i32 { 1 }");
- foo.build();
+ .file("src/lib.rs", "pub fn bar() -> i32 { 1 }")
+ .build();
foo.root().move_into_the_past();
assert_that(foo.cargo("build"),
}
}
"#)
- .file("src/lib.rs", "pub fn bar() -> i32 { 1 }");
- foo.build();
+ .file("src/lib.rs", "pub fn bar() -> i32 { 1 }")
+ .build();
foo.root().move_into_the_past();
assert_that(foo.cargo("build").env("FIRST", "1"),
version = "0.0.0"
authors = []
"#)
- .file("bar/src/main.rs", "");
- assert_that(foo.cargo_process("build"),
+ .file("bar/src/main.rs", "")
+ .build();
+ assert_that(foo.cargo("build"),
execs().with_status(0));
}
name = "foo"
path = "src/my lib.rs"
"#)
- .file("src/my lib.rs", "");
- assert_that(foo.cargo_process("build"), execs().with_status(0));
+ .file("src/my lib.rs", "")
+ .build();
+ assert_that(foo.cargo("build"), execs().with_status(0));
foo.root().move_into_the_past();
assert_that(foo.cargo("build"),
execs().with_status(0).with_stdout(""));
version = "0.0.0"
authors = []
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let dir = foo.root().join("tmp");
fs::create_dir(&dir).unwrap();
let stat = fs::metadata(&dir).unwrap();
.file("src/lib.rs", "")
.file(".cargo/config", r#"
this is not valid toml
- "#);
- assert_that(foo.cargo_process("build").arg("-v"),
+ "#)
+ .build();
+ assert_that(foo.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] Couldn't load Cargo configuration
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
- .file("dev/src/lib.rs", "pub fn dev() {}");
+ .file("dev/src/lib.rs", "pub fn dev() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
pub fn gimme() -> String {
format!("")
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101));
}
"#)
.file("bar/src/lib.rs", r#"
invalid rust file, should not be compiled
- "#);
+ "#)
+ .build();
- p.cargo_process("build").exec_with_output().unwrap();
+ p.cargo("build").exec_with_output().unwrap();
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
crate-type = ["lib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "lib"), existing_file());
}
crate-type = ["rlib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "rlib"), existing_file());
}
crate-type = ["dylib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "dylib"), existing_file());
}
crate-type = ["proc-macro"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "#![feature(proc_macro)]");
+ .file("examples/ex.rs", "#![feature(proc_macro)]")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "proc-macro"), existing_file());
}
authors = []
"#)
.file("src/main.rs", "fn main() {}")
- .file("examples/foo.rs", "fn main() {}");
+ .file("examples/foo.rs", "fn main() {}")
+ .build();
- p.cargo_process("test").arg("--no-run").arg("-v")
+ p.cargo("test").arg("--no-run").arg("-v")
.exec_with_output()
.unwrap();
version = "0.0.1"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("run").arg("-v"), execs().with_status(0));
+ assert_that(p.cargo("run").arg("-v"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
if cfg!(windows) {
// On windows unlinking immediately after running often fails, so sleep
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr_contains("\
[..] can't find crate for `bbbbb`[..]
[dependencies.foo]
path = ".."
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr("\
[ERROR] cyclic package dependency: package `a v0.0.1 ([..])` depends on itself
name = "foo"
crate-type = ["dylib", "rlib"]
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(&p.root().join("target/debug/libfoo.rlib"), existing_file());
let dylib_name = format!("{}foo{}", env::consts::DLL_PREFIX,
authors = []
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "extern crate foo_bar; fn main() {}");
+ .file("src/main.rs", "extern crate foo_bar; fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("foo-bar"), existing_file());
}
name = "foo-bar"
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "extern crate foo_bar; fn main() {}");
+ .file("src/main.rs", "extern crate foo_bar; fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101));
}
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build")
.env("RUSTC", "rustc-that-does-not-exist").arg("-v"),
.file("src/bin/a.rs", "fn main() {}")
.file("src/bin/b.rs", "fn main() {}")
.file("examples/a.rs", "fn main() {}")
- .file("examples/b.rs", "fn main() {}");
- p.build();
+ .file("examples/b.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--lib"),
execs().with_status(0));
.file("src/bin/a.rs", "fn main() {}")
.file("src/bin/b.rs", "fn main() {}")
.file("examples/a.rs", "fn main() {}")
- .file("examples/b.rs", "fn main() {}");
- p.build();
+ .file("examples/b.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--bins"),
execs().with_status(0));
.file("src/bin/a.rs", "fn main() {}")
.file("src/bin/b.rs", "fn main() {}")
.file("examples/a.rs", "fn main() {}")
- .file("examples/b.rs", "fn main() {}");
- p.build();
+ .file("examples/b.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--examples"),
execs().with_status(0));
authors = []
"#)
.file("src/bin/.a.rs", "")
- .file("src/bin/a.rs", "fn main() {}");
- p.build();
+ .file("src/bin/a.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
"#)
.file("src/bin/a.rs", "fn main() {}")
.file(".git/Cargo.toml", "")
- .file(".pc/dummy-fix.patch/Cargo.toml", "");
- p.build();
+ .file(".pc/dummy-fix.patch/Cargo.toml", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
version = "0.0.1"
authors = []
"#)
- .file("src/bin/a.rs", "fn main() {}");
- p.build();
+ .file("src/bin/a.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
let exe_name = format!("foo{}", env::consts::EXE_SUFFIX);
version = "0.0.1"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("rustc").arg("-v").arg("--").arg("-Zno-trans"),
execs().with_status(0));
name = "d2"
doctest = false
"#)
- .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }");
+ .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }")
+ .build();
- assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2")
+ assert_that(p.cargo("build").arg("-p").arg("d1").arg("-p").arg("d2")
.arg("-p").arg("foo"),
execs().with_status(0));
name = "d1"
"#)
.file("d1/src/lib.rs", "")
- .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }");
- p.build();
+ .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }")
+ .build();
assert_that(p.cargo("build").arg("-p").arg("notAValidDep"),
execs().with_status(101).with_stderr("\
version = \"0.0.1\"
authors = []
")
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
[profile.dev]
panic = 'abort'
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] -C panic=abort [..]"));
}
version = "0.0.0"
authors = []
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").arg("-v").arg("--color").arg("always"),
execs().with_status(0).with_stderr_contains(
"[..]rustc [..] src[/]lib.rs --color always[..]"));
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
- .file("bar/src/lib.rs", r#"fn dead() {}"#);
- p.build();
+ .file("bar/src/lib.rs", r#"fn dead() {}"#)
+ .build();
assert_that(p.cargo("build").arg("-v")
.arg("--message-format").arg("json"),
fn wrong_message_format_option() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--message-format").arg("XML"),
+ assert_that(p.cargo("build").arg("--message-format").arg("XML"),
execs().with_status(1)
.with_stderr_contains(
r#"[ERROR] Could not match 'xml' with any of the allowed variants: ["Human", "Json"]"#));
fn message_format_json_forward_stderr() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/main.rs", "fn main() { let unused = 0; }");
+ .file("src/main.rs", "fn main() { let unused = 0; }")
+ .build();
- assert_that(p.cargo_process("rustc").arg("--bin").arg("foo")
+ assert_that(p.cargo("rustc").arg("--bin").arg("foo")
.arg("--message-format").arg("JSON"),
execs().with_status(0)
.with_json(r#"
[package.metadata.another]
bar = 3
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("[..] foo v0.0.1 ([..])\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n"));
fn cargo_build_empty_target() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--target").arg(""),
+ assert_that(p.cargo("build").arg("--target").arg(""),
execs().with_status(101)
.with_stderr_contains("[..] target was empty"));
}
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all"),
execs().with_status(0)
.with_stderr("[..] Compiling bar v0.1.0 ([..])\n\
pub fn baz() {
break_the_build();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all")
.arg("--exclude")
.arg("baz"),
.file("bar/src/bin/e.rs", "fn main() {}")
.file("bar/src/bin/f.rs", "fn main() {}")
.file("bar/examples/g.rs", "fn main() {}")
- .file("bar/examples/h.rs", "fn main() {}");
+ .file("bar/examples/h.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all").arg("--examples"),
execs().with_status(0)
.with_stderr("[..] Compiling bar v0.1.0 ([..])\n\
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// The order in which foo and bar are built is not guaranteed
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// The order in which foo and bar are built is not guaranteed
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
.with_stderr_contains("[..] Compiling foo v0.1.0 ([..])")
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("-p").arg("foo"),
execs().with_status(0)
.with_stderr_does_not_contain("bar")
.file("bar/src/bin/e.rs", "fn main() {}")
.file("bar/src/bin/f.rs", "fn main() {}")
.file("bar/examples/g.rs", "fn main() {}")
- .file("bar/examples/h.rs", "fn main() {}");
+ .file("bar/examples/h.rs", "fn main() {}")
+ .build();
// The order in which foo and bar are built is not guaranteed
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all").arg("--examples"),
execs().with_status(0)
.with_stderr_contains("[..] Compiling bar v0.1.0 ([..])")
"#)
.file("a/src/lib.rs", r#"
pub fn a() {}
- "#);
+ "#)
+ .build();
Package::new("a", "0.1.0").publish();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all"),
execs().with_status(0)
.with_stderr("[..] Updating registry `[..]`\n\
.file("src/bin/other.rs", r#"
fn main() {
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bin").arg("other"),
+ assert_that(p.cargo("run").arg("--bin").arg("other"),
execs().with_status(0));
}
.file("src/bin/main.rs", r#"
fn main() {
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
+ assert_that(p.cargo("run").arg("--bin").arg("foo"),
execs().with_status(0));
}
fn main() {
println!("bar");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all"),
execs().with_status(0)
);
fn main() {
println!("main");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build")
+ assert_that(p.cargo("build")
.arg("--all"),
execs().with_status(0)
);
.file("src/main.rs", r#"
fn main() {
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
+ assert_that(p.cargo("run").arg("--bin").arg("foo"),
execs().with_status(0));
}
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("build").arg("-v").env("RUSTC_WRAPPER", "/usr/bin/env"),
+ assert_that(p.cargo("build").arg("-v").env("RUSTC_WRAPPER", "/usr/bin/env"),
execs().with_stderr_contains(
"[RUNNING] `/usr/bin/env rustc --crate-name foo [..]")
.with_status(0));
[lib]
crate-type = ["cdylib"]
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
let files = if cfg!(windows) {
vec!["foo.dll.lib", "foo.dll.exp", "foo.dll"]
[lib]
crate-type = ["cdylib"]
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
let files = if cfg!(windows) {
vec!["foo_bar.dll.lib", "foo_bar.dll"]
authors = []
version = "0.1.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
// We can't cross-compile the project to wasm target unless we have emscripten installed.
// So here we will not run `cargo build`, but just create cargo_rustc::Context and ask it
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.1.0 [..]
"#)
.file("src/lib.rs", "")
.file("src/main.rs", "fn main() {}")
- .file("src/bin/bar.rs", "fn main() {}");
+ .file("src/bin/bar.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
}
#[test]
name = "foo"
"#)
.file("src/lib.rs", "")
- .file("src/foo.rs", "fn main() {}");
+ .file("src/foo.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr_contains("\
[ERROR] failed to parse manifest at `[..]`
.file("src/bin/bar.rs", "fn main() {}")
.file("src/bin/bar2.rs", "fn main() {}")
.file("src/bin/bar3/main.rs", "fn main() {}")
- .file("src/bin/bar4/main.rs", "fn main() {}");
+ .file("src/bin/bar4/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(&p.bin("bar"), existing_file());
assert_that(&p.bin("bar2"), existing_file());
"#)
.file("src/main.rs", "fn main() {}")
.file("src/bin/foo.rs", "fn main() {}")
- .file("src/bin/foo/main.rs", "fn main() {}");
+ .file("src/bin/foo/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr_contains("\
[..]found duplicate binary name foo, but all binary targets must have a unique name[..]
name = "bar"
# Note, no `path` key!
"#)
- .file("src/bin/bar/main.rs", "fn main() {}");
+ .file("src/bin/bar/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("bar"), existing_file());
}
"#)
.file("src/lib.rs", "fn main() {}")
.file("examples/bar.rs", "fn main() {}")
- .file("examples/baz/main.rs", "fn main() {}");
+ .file("examples/baz/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("test"), execs().with_status(0));
+ assert_that(p.cargo("test"), execs().with_status(0));
assert_that(&p.bin("examples/bar"), existing_file());
assert_that(&p.bin("examples/baz"), existing_file());
}
"#)
.file("src/lib.rs", "fn main() {}")
.file("tests/bar.rs", "fn main() {}")
- .file("tests/baz/main.rs", "fn main() {}");
+ .file("tests/baz/main.rs", "fn main() {}")
+ .build();
assert_that(
- p.cargo_process("test").arg("--test=bar").arg("--test=baz"),
+ p.cargo("test").arg("--test=bar").arg("--test=baz"),
execs().with_status(0));
}
authors = []
"#)
.file("src/lib.rs", "fn main() {}")
- .file("benches/bar.rs", "fn main() {}");
+ .file("benches/bar.rs", "fn main() {}")
+ .build();
assert_that(
- p.cargo_process("bench").arg("--bench=bar"),
+ p.cargo("bench").arg("--bench=bar"),
execs().with_status(0));
}
authors = []
"#)
.file("src/lib.rs", "fn main() {}")
- .file("benches/bar/main.rs", "fn main() {}");
+ .file("benches/bar/main.rs", "fn main() {}")
+ .build();
assert_that(
- p.cargo_process("bench").arg("--bench=bar"),
+ p.cargo("bench").arg("--bench=bar"),
execs().with_status(0));
}
// same metadata hash.
let p = project("foo1")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
let output = t!(String::from_utf8(
- t!(p.cargo_process("build").arg("-v").exec_with_output())
+ t!(p.cargo("build").arg("-v").exec_with_output())
.stderr,
));
let metadata = output
let p = project("foo2")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
assert_that(
- p.cargo_process("build").arg("-v"),
+ p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr_contains(
format!("[..]{}[..]", metadata),
),
[dependencies]
testless = "0.1.0"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr_contains(
authors = []
im-a-teapot = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build")
.masquerade_as_nightly_cargo(),
execs().with_status(101)
.with_stderr("\
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
error: failed to parse manifest at `[..]`
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
warning: the cargo feature `test-dummy-stable` is now stable and is no longer \
authors = []
im-a-teapot = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build")
.masquerade_as_nightly_cargo(),
execs().with_status(0)
.with_stderr("\
authors = []
im-a-teapot = true
"#)
- .file("a/src/lib.rs", "");
- assert_that(p.cargo_process("build")
+ .file("a/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build")
.masquerade_as_nightly_cargo(),
execs().with_status(0)
.with_stderr("\
authors = []
im-a-teapot = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build")
.masquerade_as_nightly_cargo(),
execs().with_status(0)
.with_stderr("\
authors = []
im-a-teapot = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build")
.arg("-Zprint-im-a-teapot"),
execs().with_status(101)
.with_stderr("\
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("package")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("package")
.masquerade_as_nightly_cargo(),
execs().with_status(101)
.with_stderr("\
use cargotest::cargo_process;
use cargotest::support::paths::{self, CargoPathExt};
-use cargotest::support::{execs, project, ProjectBuilder, basic_bin_manifest};
+use cargotest::support::{execs, project, Project, basic_bin_manifest};
use hamcrest::{assert_that, existing_file};
#[cfg_attr(windows,allow(dead_code))]
}
/// Add an empty file with executable flags (and platform-dependent suffix).
-/// TODO: move this to `ProjectBuilder` if other cases using this emerge.
-fn fake_file(proj: ProjectBuilder, dir: &Path, name: &str, kind: &FakeKind) -> ProjectBuilder {
+/// TODO: move this to `Project` if other cases using this emerge.
+fn fake_file(proj: Project, dir: &Path, name: &str, kind: &FakeKind) -> Project {
let path = proj.root().join(dir).join(&format!("{}{}", name,
env::consts::EXE_SUFFIX));
path.parent().unwrap().mkdir_p();
#[test]
fn list_command_looks_at_path() {
- let proj = project("list-non-overlapping");
+ let proj = project("list-non-overlapping").build();
let proj = fake_file(proj, Path::new("path-test"), "cargo-1", &FakeKind::Executable);
let mut pr = cargo_process();
fn list_command_resolves_symlinks() {
use cargotest::support::cargo_exe;
- let proj = project("list-non-overlapping");
+ let proj = project("list-non-overlapping").build();
let proj = fake_file(proj, Path::new("path-test"), "cargo-2",
&FakeKind::Symlink{target:&cargo_exe()});
let mut pr = cargo_process();
let p = project("cargo-envtest")
.file("Cargo.toml", &basic_bin_manifest("cargo-envtest"))
- .file("src/main.rs", &src);
+ .file("src/main.rs", &src)
+ .build();
let target_dir = p.target_debug_dir();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("cargo-envtest"), existing_file());
let mut pr = cargo_process();
.file(".cargo/config",r#"
[alias]
b-cargo-test = 5
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("b-cargo-test").arg("-v"),
+ assert_that(p.cargo("b-cargo-test").arg("-v"),
execs().with_status(101).
with_stderr_contains("[ERROR] invalid configuration \
for key `alias.b-cargo-test`
.file(".cargo/config",r#"
[alias]
b = "not_build"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("b").arg("-v"),
+ assert_that(p.cargo("b").arg("-v"),
execs().with_status(0).
with_stderr_contains("[COMPILING] foo v0.5.0 [..]"));
}
.file(".cargo/config",r#"
[alias]
b-cargo-test = "build"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("b-cargo-test").arg("-v"),
+ assert_that(p.cargo("b-cargo-test").arg("-v"),
execs().with_status(0).
with_stderr_contains("[COMPILING] foo v0.5.0 [..]
[RUNNING] `rustc --crate-name foo [..]"));
.file(".cargo/config",r#"
[alias]
b-cargo-test = ["build", "--release"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("b-cargo-test").arg("-v"),
+ assert_that(p.cargo("b-cargo-test").arg("-v"),
execs().with_status(0).
with_stderr_contains("[COMPILING] foo v0.5.0 [..]").
with_stderr_contains("[RUNNING] `rustc --crate-name [..]")
.file(".cargo/config",r#"
[alias]
b-cargo-test = "build --release"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("b-cargo-test").arg("-v"),
+ assert_that(p.cargo("b-cargo-test").arg("-v"),
execs().with_status(0).
with_stderr_contains("[COMPILING] foo v0.5.0 [..]").
with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]")
.file(".cargo/config",r#"
[alias]
build = "fetch"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.5.0 ([..])
CHECK.call_once(|| {
let p = project("cross_test")
.file("Cargo.toml", &basic_bin_manifest("cross_test"))
- .file("src/cross_test.rs", &main_file(r#""testing!""#, &[]));
+ .file("src/cross_test.rs", &main_file(r#""testing!""#, &[]))
+ .build();
- let result = p.cargo_process("build")
+ let result = p.cargo("build")
.arg("--target").arg(&cross_target)
.exec_with_output();
_ => unreachable!(),
};
format!("{}-{}", arch, platform)
-}
\ No newline at end of file
+}
use git2;
use cargo::util::ProcessError;
-use support::{ProjectBuilder, project, path2url};
+use support::{ProjectBuilder, Project, project, path2url};
+#[must_use]
pub struct RepoBuilder {
repo: git2::Repository,
files: Vec<PathBuf>,
}
+pub struct Repository(git2::Repository);
+
pub fn repo(p: &Path) -> RepoBuilder { RepoBuilder::init(p) }
impl RepoBuilder {
self
}
- pub fn build(&self) {
- let mut index = t!(self.repo.index());
- for file in self.files.iter() {
- t!(index.add_path(file));
+ pub fn build(self) -> Repository {
+ {
+ let mut index = t!(self.repo.index());
+ for file in self.files.iter() {
+ t!(index.add_path(file));
+ }
+ t!(index.write());
+ let id = t!(index.write_tree());
+ let tree = t!(self.repo.find_tree(id));
+ let sig = t!(self.repo.signature());
+ t!(self.repo.commit(Some("HEAD"), &sig, &sig,
+ "Initial commit", &tree, &[]));
}
- t!(index.write());
- let id = t!(index.write_tree());
- let tree = t!(self.repo.find_tree(id));
- let sig = t!(self.repo.signature());
- t!(self.repo.commit(Some("HEAD"), &sig, &sig,
- "Initial commit", &tree, &[]));
+ let RepoBuilder{ repo, .. } = self;
+ Repository(repo)
}
+}
+impl Repository {
pub fn root(&self) -> &Path {
- self.repo.workdir().unwrap()
+ self.0.workdir().unwrap()
}
pub fn url(&self) -> Url {
- path2url(self.repo.workdir().unwrap().to_path_buf())
+ path2url(self.0.workdir().unwrap().to_path_buf())
}
}
-pub fn new<F>(name: &str, callback: F) -> Result<ProjectBuilder, ProcessError>
+pub fn new<F>(name: &str, callback: F) -> Result<Project, ProcessError>
where F: FnOnce(ProjectBuilder) -> ProjectBuilder
{
let mut git_project = project(name);
git_project = callback(git_project);
- git_project.build();
+ let git_project = git_project.build();
let repo = t!(git2::Repository::init(&git_project.root()));
let mut cfg = t!(repo.config());
-use std::cell::Cell;
use std::env;
use std::error::Error;
use std::ffi::OsStr;
}
}
+#[derive(PartialEq,Clone)]
+pub struct Project{
+ root: PathBuf,
+}
+
+#[must_use]
#[derive(PartialEq,Clone)]
pub struct ProjectBuilder {
name: String,
- root: PathBuf,
+ root: Project,
files: Vec<FileBuilder>,
symlinks: Vec<SymlinkBuilder>,
- is_build: Cell<bool>,
}
impl ProjectBuilder {
+ pub fn root(&self) -> PathBuf {
+ self.root.root()
+ }
+
+ pub fn build_dir(&self) -> PathBuf {
+ self.root.build_dir()
+ }
+
+ pub fn target_debug_dir(&self) -> PathBuf {
+ self.root.target_debug_dir()
+ }
+
pub fn new(name: &str, root: PathBuf) -> ProjectBuilder {
ProjectBuilder {
name: name.to_string(),
- root: root,
+ root: Project{ root },
files: vec![],
symlinks: vec![],
- is_build: Cell::new(false),
}
}
+ pub fn file<B: AsRef<Path>>(mut self, path: B,
+ body: &str) -> Self {
+ self._file(path.as_ref(), body);
+ self
+ }
+
+ fn _file(&mut self, path: &Path, body: &str) {
+ self.files.push(FileBuilder::new(self.root.root.join(path), body));
+ }
+
+ pub fn symlink<T: AsRef<Path>>(mut self, dst: T,
+ src: T) -> Self {
+ self.symlinks.push(SymlinkBuilder::new(self.root.root.join(dst),
+ self.root.root.join(src)));
+ self
+ }
+
+ pub fn build(self) -> Project {
+ // First, clean the directory if it already exists
+ self.rm_root();
+
+ // Create the empty directory
+ self.root.root.mkdir_p();
+
+ for file in self.files.iter() {
+ file.mk();
+ }
+
+ for symlink in self.symlinks.iter() {
+ symlink.mk();
+ }
+
+ let ProjectBuilder{ name: _, root, files: _, symlinks: _, .. } = self;
+ root
+ }
+
+ fn rm_root(&self) {
+ self.root.root.rm_rf()
+ }
+}
+
+impl Project {
pub fn root(&self) -> PathBuf {
self.root.clone()
}
- pub fn url(&self) -> Url { path2url(self.root()) }
+ pub fn build_dir(&self) -> PathBuf {
+ self.root.join("target")
+ }
pub fn target_debug_dir(&self) -> PathBuf {
self.build_dir().join("debug")
}
+ pub fn url(&self) -> Url { path2url(self.root()) }
+
pub fn example_lib(&self, name: &str, kind: &str) -> PathBuf {
- let prefix = ProjectBuilder::get_lib_prefix(kind);
+ let prefix = Project::get_lib_prefix(kind);
- let extension = ProjectBuilder::get_lib_extension(kind);
+ let extension = Project::get_lib_extension(kind);
let lib_file_name = format!("{}{}.{}",
prefix,
.join(&format!("{}{}", b, env::consts::EXE_SUFFIX))
}
- pub fn build_dir(&self) -> PathBuf {
- self.root.join("target")
+ pub fn change_file(&self, path: &str, body: &str) {
+ FileBuilder::new(self.root.join(path), body).mk()
}
pub fn process<T: AsRef<OsStr>>(&self, program: T) -> ProcessBuilder {
}
pub fn cargo(&self, cmd: &str) -> ProcessBuilder {
- assert!(self.is_build.get(),
- "call `.build()` before calling `.cargo()`, \
- or use `.cargo_process()`");
let mut p = self.process(&cargo_exe());
p.arg(cmd);
return p;
}
- pub fn cargo_process(&self, cmd: &str) -> ProcessBuilder {
- self.build();
- self.cargo(cmd)
- }
-
- pub fn file<B: AsRef<Path>>(mut self, path: B,
- body: &str) -> ProjectBuilder {
- self._file(path.as_ref(), body);
- self
- }
-
- fn _file(&mut self, path: &Path, body: &str) {
- self.files.push(FileBuilder::new(self.root.join(path), body));
- }
-
- pub fn change_file(&self, path: &str, body: &str) {
- assert!(self.is_build.get());
- FileBuilder::new(self.root.join(path), body).mk()
- }
-
- pub fn symlink<T: AsRef<Path>>(mut self, dst: T,
- src: T) -> ProjectBuilder {
- self.symlinks.push(SymlinkBuilder::new(self.root.join(dst),
- self.root.join(src)));
- self
- }
-
- // TODO: return something different than a ProjectBuilder
- pub fn build(&self) -> &ProjectBuilder {
- assert!(!self.is_build.get(),
- "can `.build()` project only once");
- self.is_build.set(true);
- // First, clean the directory if it already exists
- self.rm_root();
-
- // Create the empty directory
- self.root.mkdir_p();
-
- for file in self.files.iter() {
- file.mk();
- }
-
- for symlink in self.symlinks.iter() {
- symlink.mk();
- }
- self
- }
-
pub fn read_lockfile(&self) -> String {
let mut buffer = String::new();
fs::File::open(self.root().join("Cargo.lock")).unwrap()
_ => unreachable!()
}
}
-
- fn rm_root(&self) {
- self.root.rm_rf()
- }
}
// Generates a project layout
use std::fs::{self, File};
use support::paths;
-use support::git::repo;
+use support::git::{repo, Repository};
use url::Url;
-pub fn setup() {
+pub fn setup() -> Repository {
let config = paths::root().join(".cargo/config");
t!(fs::create_dir_all(config.parent().unwrap()));
t!(t!(File::create(&config)).write_all(br#"
"dl": "{0}",
"api": "{0}"
}}"#, upload()))
- .build();
+ .build()
}
fn registry_path() -> PathBuf { paths::root().join("registry") }
pub fn registry() -> Url { Url::from_file_path(&*registry_path()).ok().unwrap() }
pub fn upload_path() -> PathBuf { paths::root().join("upload") }
-fn upload() -> Url { Url::from_file_path(&*upload_path()).ok().unwrap() }
\ No newline at end of file
+fn upload() -> Url { Url::from_file_path(&*upload_path()).ok().unwrap() }
"#, reg = registry()).as_bytes()));
// Init a new registry
- repo(®istry_path())
+ let _ = repo(®istry_path())
.file("config.json", &format!(r#"
{{"dl":"{0}","api":"{0}"}}
"#, dl_url()))
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[COMPILING] a v0.0.1 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[dependencies]
bar = "0.1.0"
"#)
- .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;");
+ .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry [..]
[DOWNLOADING] [..]
[target.'cfg({})'.dependencies]
foo = "0.2.0"
"#, this_family, other_family))
- .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate foo;");
+ .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate foo;")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry [..]
[DOWNLOADING] [..]
[target.'cfg(4)'.dependencies]
bar = "0.1.0"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[target.'cfg(foo =)'.dependencies]
bar = "0.1.0"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("b/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
fn main() {
::bar::baz();
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("check"),
+ assert_that(foo.cargo("check"),
execs().with_status(0));
}
fn main() {
::bar::baz(42);
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("check"),
+ assert_that(foo.cargo("check"),
execs().with_status(101));
}
let a = A;
a.b();
}
-"#);
- let bar = project("bar")
+"#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
pub fn derive(_input: TokenStream) -> TokenStream {
format!("impl B for A {{ fn b(&self) {{}} }}").parse().unwrap()
}
-"#);
- bar.build();
+"#)
+ .build();
- assert_that(foo.cargo_process("check"),
+ assert_that(foo.cargo("check"),
execs().with_status(0));
}
fn main() {
::bar::baz();
}
- "#);
- foo.build();
+ "#)
+ .build();
- let bar = project("bar")
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("check"),
execs().with_status(0));
fn main() {
::bar::baz();
}
- "#);
- foo.build();
+ "#)
+ .build();
- let bar = project("bar")
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("build"),
execs().with_status(0));
[dependencies]
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(foo.cargo_process("check").arg("-v"),
+ assert_that(foo.cargo("check").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] --emit=dep-info,metadata [..]"));
}
// checked, but in this case with a proc macro too.
#[test]
fn issue_3419() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
fn main() {
foo::take::<Foo>();
}
- "#);
+ "#)
+ .build();
Package::new("rustc-serialize", "1.0.0")
.file("src/lib.rs",
where F: FnOnce(&mut Self) -> Result<T, Self::Error>;
} "#).publish();
- assert_that(foo.cargo_process("check"),
+ assert_that(p.cargo("check"),
execs().with_status(0));
}
fn main() {
::bar::baz();
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustc")
+ assert_that(foo.cargo("rustc")
.arg("--profile")
.arg("check")
.arg("--")
fn main() {
::bar::qux();
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustc")
+ assert_that(foo.cargo("rustc")
.arg("--profile")
.arg("check")
.arg("--")
#[test]
fn check_all() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
authors = []
"#)
.file("b/src/main.rs", "fn main() {}")
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(foo.cargo_process("check").arg("--all").arg("-v"),
+ assert_that(p.cargo("check").arg("--all").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
.with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("check").arg("-v"),
+ assert_that(p.cargo("check").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] --crate-name foo foo[/]src[/]lib.rs [..]")
.with_stderr_contains("[..] --crate-name bar bar[/]src[/]lib.rs [..]")
.file("examples/example1.rs", "fn main() {}")
.file("tests/test2.rs", "#[test] fn t() {}")
.file("benches/bench3.rs", "")
- ;
+ .build();
- assert_that(foo.cargo_process("check").arg("--all-targets").arg("-v"),
+ assert_that(foo.cargo("check").arg("--all-targets").arg("-v"),
execs().with_status(0)
.with_stderr_contains("[..] --crate-name foo src[/]lib.rs [..]")
.with_stderr_contains("[..] --crate-name foo src[/]main.rs [..]")
#[test]
fn cargo_clean_simple() {
let p = project("foo")
- .file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.build_dir(), existing_dir());
assert_that(p.cargo("clean"),
#[test]
fn different_dir() {
let p = project("foo")
- .file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
- .file("src/bar/a.rs", "");
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .file("src/bar/a.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.build_dir(), existing_dir());
assert_that(p.cargo("clean").cwd(&p.root().join("src")),
[[bin]]
name = "d2"
"#)
- .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }");
+ .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }")
+ .build();
- assert_that(p.cargo_process("build").arg("-p").arg("d1").arg("-p").arg("d2")
+ assert_that(p.cargo("build").arg("-p").arg("d1").arg("-p").arg("d2")
.arg("-p").arg("foo"),
execs().with_status(0));
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").arg("--release"),
execs().with_status(0));
}
}
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").env("FIRST", "1"),
execs().with_status(0));
[dependencies]
dep = {{ git = '{}' }}
"#, git.url()))
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
[dependencies]
bar = "0.1"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.1.0").publish();
version = "0.0.0"
"#)
.file("b/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
let mut a = p.cargo("install").cwd(p.root().join("a")).build_command();
let mut b = p.cargo("install").cwd(p.root().join("b")).build_command();
version = "0.0.0"
"#)
.file("b/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
let mut a = p.cargo("install").cwd(p.root().join("a")).build_command();
let mut b = p.cargo("install").cwd(p.root().join("b")).build_command();
bar = "*"
"#)
.file("b/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
let mut a = p.cargo("build").cwd(p.root().join("a")).build_command();
let mut b = p.cargo("build").cwd(p.root().join("b")).build_command();
dep = {{ git = '{}', tag = 'tag2' }}
"#, a.url()))
.file("b/src/main.rs", "extern crate dep; fn main() { dep::tag2(); }");
- p.build();
+ let p = p.build();
let mut a = p.cargo("build").arg("-v").cwd(p.root().join("a")).build_command();
let mut b = p.cargo("build").arg("-v").cwd(p.root().join("b")).build_command();
dep = {{ git = '{}' }}
"#, a.url()))
.file("b/src/main.rs", "extern crate dep; fn main() { dep::f2(); }");
- p.build();
+ let p = p.build();
// Generate a Cargo.lock pointing at the current rev, then clear out the
// target directory
"#)
.file("src/main.rs", "fn main() {}")
.file("src/lib.rs", "");
- p.build();
+ let p = p.build();
let mut a = p.cargo("build").build_command();
let mut b = p.cargo("build").build_command();
}
}
"#);
- p.build();
+ let p = p.build();
// Our build script will connect to our local TCP socket to inform us that
// it's started and that's how we know that `a` will have the lock
version = "0.0.0"
"#)
.file("src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
fs::remove_dir_all(p.root().join("target")).unwrap();
dep2 = {{ git = '{}' }}
"#, dep1.url(), dep2.url()))
.file("src/main.rs", "fn main() { }");
- p.build();
+ let p = p.build();
let n_concurrent_builds = 5;
fn main() {
assert_eq!(env::var("NUM_JOBS").unwrap(), "100");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").env("CARGO_BUILD_JOBS", "100"),
+ assert_that(p.cargo("build").env("CARGO_BUILD_JOBS", "100"),
execs().with_status(0));
}
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(p.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
.file("src/main.rs", r#"
extern crate bar;
fn main() { bar::bar(); }
- "#);
- let p2 = project("bar")
+ "#)
+ .build();
+ let _p2 = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "pub fn bar() {}");
- p2.build();
+ .file("src/lib.rs", "pub fn bar() {}")
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("build").arg("--target").arg(&target),
+ assert_that(p.cargo("build").arg("--target").arg(&target),
execs().with_status(0));
assert_that(&p.target_bin(&target, "foo"), existing_file());
fn main() {
assert_eq!(bar!(), baz::baz());
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
-> Box<MacResult + 'static> {
MacEager::expr(quote_expr!(cx, 1))
}
- "#);
- let baz = project("baz")
+ "#)
+ .build();
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[package]
name = "baz"
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "pub fn baz() -> i32 { 1 }");
- bar.build();
- baz.build();
+ .file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
+ .build();
let target = cross_compile::alternate();
- assert_that(foo.cargo_process("build").arg("--target").arg(&target),
+ assert_that(foo.cargo("build").arg("--target").arg(&target),
execs().with_status(0));
assert_that(&foo.target_bin(&target, "foo"), existing_file());
fn main() {
assert_eq!(bar!(), baz::baz());
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
-> Box<MacResult + 'static> {
MacEager::expr(quote_expr!(cx, baz::baz()))
}
- "#);
- let baz = project("baz")
+ "#)
+ .build();
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[package]
name = "baz"
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "pub fn baz() -> i32 { 1 }");
- bar.build();
- baz.build();
+ .file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
+ .build();
let target = cross_compile::alternate();
- assert_that(foo.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(foo.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
println!("second");
assert_that(foo.cargo("build").arg("-v")
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
- assert_that(p.cargo_process("build").arg("--target").arg(&target)
+ assert_that(p.cargo("build").arg("--target").arg(&target)
.arg("-v"),
execs().with_status(101)
.with_stderr_contains(&format!("\
#![plugin(bar)]
fn main() {}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
pub fn foo(reg: &mut Registry) {
println!("{}", baz::baz());
}
- "#);
- let baz = project("baz")
+ "#)
+ .build();
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[package]
name = "baz"
name = "baz"
crate_type = ["dylib"]
"#)
- .file("src/lib.rs", "pub fn baz() -> i32 { 1 }");
- bar.build();
- baz.build();
+ .file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
+ .build();
let target = cross_compile::alternate();
- assert_that(foo.cargo_process("build").arg("--target").arg(&target),
+ assert_that(foo.cargo("build").arg("--target").arg(&target),
execs().with_status(0));
}
use std::env;
pub fn foo() {{ assert_eq!(env::consts::ARCH, "{}"); }}
#[test] fn test_foo() {{ foo() }}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("test").arg("--target").arg(&target),
+ assert_that(p.cargo("test").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.0 ({foo})
//! extern crate foo;
//! assert!(true);
//! ```
- "#);
- p.build();
+ "#)
+ .build();
let host_output = format!("\
[COMPILING] foo v0.0.0 ({foo})
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("run").arg("--target").arg(&target),
+ assert_that(p.cargo("run").arg("--target").arg(&target),
execs().with_status(0));
}
assert_eq!(path.file_name().unwrap().to_str().unwrap(), "target");
}}
"#, target))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(p.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.0 (file://[..])
#[allow(unused_extern_crates)]
extern crate d1;
pub fn d2() { d1::d1(); }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(p.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0)
.with_stderr_contains(&format!("\
[COMPILING] d1 v0.0.0 ({url}/d1)", url = p.url()))
path = "../d1"
"#)
.file("d2/build.rs", "extern crate d1; fn main() {}")
- .file("d2/src/lib.rs", "");
+ .file("d2/src/lib.rs", "")
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(p.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
}
.contains("target/debug/build/d1-"),
"bad: {:?}", env::var("OUT_DIR"));
}
- "#);
+ "#)
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
+ assert_that(p.cargo("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
}
plugin = true
"#)
.file("build.rs", "fn main() {}")
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(cross_compile::alternate()),
+ assert_that(p.cargo("build").arg("-v").arg("--target").arg(cross_compile::alternate()),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo v0.0.1 ([..])
version = "0.0.0"
authors = []
"#)
- .file("d2/src/lib.rs", "");
+ .file("d2/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
+ assert_that(p.cargo("build").arg("-v").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] d2 v0.0.0 ([..])
version = "0.0.0"
authors = []
"#)
- .file("d2/src/lib.rs", "");
+ .file("d2/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(&target),
+ assert_that(p.cargo("build").arg("-v").arg("--target").arg(&target),
execs().with_status(101)
.with_stderr_contains("\
[..] can't find crate for `d2`[..]"));
.file("d2/build.rs", r#"
fn main() { println!("cargo:val=1") }
"#)
- .file("d2/src/lib.rs", "");
- p.build();
+ .file("d2/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
assert_that(p.cargo("build").arg("-v").arg("--target").arg(&target),
pub fn baz() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
- assert_that(p.cargo_process("test").arg("--target").arg(&target),
+ assert_that(p.cargo("test").arg("--target").arg(&target),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
- assert_that(p.cargo_process("package").arg("--target").arg(&target),
+ assert_that(p.cargo("package").arg("--target").arg(&target),
execs().with_status(0).with_status(0).with_stderr(&format!(
" Packaging foo v0.0.0 ({dir})
Verifying foo v0.0.0 ({dir})
fn main() {{
assert_eq!(env::consts::ARCH, "{}");
}}
- "#, cross_compile::alternate_arch()));
-
- p.build();
+ "#, cross_compile::alternate_arch()))
+ .build();
let target = cross_compile::alternate();
Finished dev [unoptimized + debuginfo] target(s) in [..]
Uploading foo v0.0.0 ({dir})
", dir = p.url(), registry = publish::registry())));
-}
\ No newline at end of file
+}
let _ = socket.read(&mut [0; 10]);
panic!("that read should never return");
}}
- "#, addr));
- p.build();
+ "#, addr))
+ .build();
let mut cargo = p.cargo("build").build_command();
cargo.stdin(Stdio::piped())
fn build_dep_info() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
let depinfo_bin_path = &p.bin("foo").with_extension("d");
crate-type = ["lib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "lib").with_extension("d"), existing_file());
}
crate-type = ["rlib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "rlib").with_extension("d"), existing_file());
}
crate-type = ["dylib"]
"#)
.file("src/lib.rs", "")
- .file("examples/ex.rs", "");
+ .file("examples/ex.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--example=ex"), execs().with_status(0));
+ assert_that(p.cargo("build").arg("--example=ex"), execs().with_status(0));
assert_that(&p.example_lib("ex", "dylib").with_extension("d"), existing_file());
}
let p = self.p.take().unwrap();
let json = serde_json::to_string(&self.cksum).unwrap();
let p = p.file(".cargo-checksum.json", &json);
- p.build();
+ let _ = p.build();
}
}
pub fn bar() {
foo::foo();
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
fn not_there() {
setup();
- project("index").build();
+ let _ = project("index").build();
let p = project("bar")
.file("Cargo.toml", r#"
pub fn bar() {
foo::foo();
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
pub fn bar() {
foo::foo();
}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
pub fn bar() {
foo::foo();
}
- "#);
- p.build();
+ "#)
+ .build();
let cksum = Package::new("foo", "0.1.0")
.file("src/lib.rs", "pub fn foo() -> u32 { 0 }")
[dependencies]
foo = "0.1.0"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
Package::new("foo", "0.1.0").publish();
[dependencies]
foo = "0.1.0"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[dependencies]
foo = "0.1.0"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"), execs().with_status(0));
}
[dependencies]
git = {{ git = '{0}' }}
"#, git.url()))
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"), execs().with_status(0));
[dependencies]
git = { git = 'https://example.com/' }
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
let root = paths::root();
t!(fs::create_dir(&root.join(".cargo")));
.file("build.rs", "fn main() {}")
.file("src/lib.rs", r#"
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0).with_stderr(&format!("\
[..] foo v0.0.1 ({dir})
[..] foo v0.0.1 ({dir})
"#)
.file("src/main.rs", r#"
bad code
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0));
}
"#)
.file("src/lib.rs", r#"
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0).with_stderr(&format!("\
[DOCUMENTING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0).with_stderr(&format!("\
[..] bar v0.0.1 ({dir}/bar)
[..] bar v0.0.1 ({dir}/bar)
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc").arg("--no-deps"),
+ assert_that(p.cargo("doc").arg("--no-deps"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
[DOCUMENTING] foo v0.0.1 ({dir})
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc").arg("-v"),
+ assert_that(p.cargo("doc").arg("-v"),
execs().with_status(0));
assert_that(&p.root().join("target/doc"), existing_dir());
[lib]
name = "foo_lib"
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("doc").arg("--all"),
+ assert_that(p.cargo("doc").arg("--all"),
execs()
.with_status(101)
.with_stderr_contains("[..] library `foo_lib` is specified [..]")
[lib]
name = "foo_lib"
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("doc").arg("--all"),
+ assert_that(p.cargo("doc").arg("--all"),
execs()
.with_status(101)
.with_stderr_contains("[..] target `foo_lib` [..]")
[[bin]]
name = "foo-cli"
"#)
- .file("bar/src/foo-cli.rs", "");
+ .file("bar/src/foo-cli.rs", "")
+ .build();
- assert_that(p.cargo_process("doc").arg("--all"),
+ assert_that(p.cargo("doc").arg("--all"),
execs()
.with_status(101)
.with_stderr_contains("[..] binary `foo_cli` is specified [..]")
name = "foo-cli"
doc = false
"#)
- .file("bar/src/foo-cli.rs", "");
+ .file("bar/src/foo-cli.rs", "")
+ .build();
- assert_that(p.cargo_process("doc").arg("--all"),
+ assert_that(p.cargo("doc").arg("--all"),
execs().with_status(0));
}
authors = []
"#)
.file("src/main.rs", "fn main() {}")
- .file("src/lib.rs", "fn foo() {}");
+ .file("src/lib.rs", "fn foo() {}")
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(101)
.with_stderr("\
[ERROR] The target `foo` is specified as a library and as a binary by package \
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("doc").arg("-p").arg("a"),
+ assert_that(p.cargo("doc").arg("-p").arg("a"),
execs().with_status(0)
.with_stderr("\
[..] b v0.0.1 (file://[..])
.file("src/lib.rs", "")
.file("src/bin/main.rs", "fn main() {}")
.file("examples/main.rs", "fn main() {}")
- .file("tests/main.rs", "fn main() {}");
+ .file("tests/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0));
}
extern {
pub static A: u32;
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc").arg("--target").arg(TARGET).arg("--verbose"),
+ assert_that(p.cargo("doc").arg("--target").arg(TARGET).arg("--verbose"),
execs().with_status(0));
assert_that(&p.root().join(&format!("target/{}/doc", TARGET)), existing_dir());
assert_that(&p.root().join(&format!("target/{}/doc/foo/index.html", TARGET)), existing_file());
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "not rust");
+ .file("a/src/lib.rs", "not rust")
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0));
}
/// ☃
/// ```
pub fn foo() {}
- ");
+ ")
+ .build();
- let error = p.cargo_process("doc").exec_with_output().err().unwrap();
+ let error = p.cargo("doc").exec_with_output().err().unwrap();
if let CargoError(CargoErrorKind::ProcessErrorKind(perr), ..) = error {
let output = perr.output.unwrap();
let stderr = str::from_utf8(&output.stderr).unwrap();
.file("a/src/lib.rs", "
/// test
pub fn foo() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0));
}
/// ☃
/// ```
pub fn foo() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--release"),
+ assert_that(p.cargo("build").arg("--release"),
execs().with_status(0));
assert_that(p.cargo("doc").arg("--release").arg("-v"),
execs().with_status(0)
"#)
.file("baz/src/lib.rs", r#"
pub fn baz() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("doc")
+ assert_that(p.cargo("doc")
.arg("-p").arg("bar")
.arg("-p").arg("baz")
.arg("-v"),
.file("bar/src/lib.rs", r#"
#[cfg(feature = "bar")]
pub fn bar() {}
- "#);
- assert_that(p.cargo_process("doc").arg("--features").arg("foo"),
+ "#)
+ .build();
+ assert_that(p.cargo("doc").arg("--features").arg("foo"),
execs().with_status(0));
assert_that(&p.root().join("target/doc"), existing_dir());
assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
.file("src/lib.rs", r#"
/// dox
pub fn foo() {}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("doc"),
execs().with_status(0));
/// ```
pub fn foo() {}
fn main() { foo(); }
- "#);
- assert_that(p.cargo_process("doc").arg("--lib"),
+ "#)
+ .build();
+ assert_that(p.cargo("doc").arg("--lib"),
execs().with_status(0));
assert_that(&p.root().join("target/doc/foo/index.html"), existing_file());
}
[lib]
proc-macro = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("doc")
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("doc")
.arg("--target=x86_64-unknown-openbsd")
.arg("-v"),
execs().with_status(0));
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// The order in which bar is compiled or documented is not deterministic
- assert_that(p.cargo_process("doc")
+ assert_that(p.cargo("doc")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// The order in which foo and bar are documented is not guaranteed
- assert_that(p.cargo_process("doc")
+ assert_that(p.cargo("doc")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// The order in which foo and bar are documented is not guaranteed
- assert_that(p.cargo_process("doc"),
+ assert_that(p.cargo("doc"),
execs().with_status(0)
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
.with_stderr_contains("[..] Documenting foo v0.1.0 ([..])"));
"#)
.file("a/src/lib.rs", r#"
pub fn a() {}
- "#);
+ "#)
+ .build();
Package::new("a", "0.1.0").publish();
- assert_that(p.cargo_process("doc")
+ assert_that(p.cargo("doc")
.arg("--all"),
execs().with_status(0)
.with_stderr_contains("[..] Updating registry `[..]`")
[features]
bar = ["baz"]
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[dependencies.bar]
path = "foo"
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[dependencies.baz]
path = "foo"
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
- p.build();
+ .file("bar/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
path = "bar"
optional = true
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
[features]
foo = ["bar/baz"]
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("foo"),
+ assert_that(p.cargo("build").arg("--features").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
foo = ["bar/baz"]
bar = []
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("foo"),
+ assert_that(p.cargo("build").arg("--features").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("foo"),
+ assert_that(p.cargo("build").arg("--features").arg("foo"),
execs().with_status(101).with_stderr("\
[ERROR] feature names may not contain slashes: `foo/bar`
"));
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("bar"),
+ assert_that(p.cargo("build").arg("--features").arg("bar"),
execs().with_status(0).with_stderr("\
warning: Package `foo v0.0.1 ([..])` does not have feature `bar`. It has a required dependency with \
that name, but only optional dependencies can be used as features. [..]
version = "0.0.1"
authors = []
"#)
- .file("bar/baz/src/lib.rs", "");
+ .file("bar/baz/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
warning: Package `bar v0.0.1 ([..])` does not have feature `baz`. It has a required dependency with \
that name, but only optional dependencies can be used as features. [..]
.file("bar/src/lib.rs", r#"
#[cfg(feature = "qux")]
pub fn test() { print!("test"); }
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] feature names may not contain slashes: `bar/qux`
"));
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "pub fn bar() {}");
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "pub fn bar() {}");
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
[COMPILING] foo v0.0.1 ({dir})
[features]
default = ["default"]
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] Cyclic feature dependency: feature `default` depends on itself
"));
foo = ["bar"]
bar = ["foo"]
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
}
version = "0.0.1"
authors = []
"#)
- .file("baz/src/lib.rs", "pub fn baz() {}");
+ .file("baz/src/lib.rs", "pub fn baz() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
version = "0.0.1"
authors = []
"#)
- .file("baz/src/lib.rs", "pub fn baz() {}");
+ .file("baz/src/lib.rs", "pub fn baz() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("bar baz"),
+ assert_that(p.cargo("build").arg("--features").arg("bar baz"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
.file("d2/src/lib.rs", r#"
#[cfg(feature = "f1")] pub fn f1() {}
#[cfg(feature = "f2")] pub fn f2() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] d2 v0.0.1 ({dir}/d2)
[COMPILING] d1 v0.0.1 ({dir}/d1)
ftest2 = []
fall = ["ftest", "ftest2"]
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] a v0.1.0 ({dir}/a)
[COMPILING] b v0.1.0 ({dir})
version = "0.0.1"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg(""),
+ assert_that(p.cargo("build").arg("--features").arg(""),
execs().with_status(0));
}
.file("bar/src/lib.rs", r#"
#[cfg(feature = "baz")]
pub fn baz() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("foo"),
+ assert_that(p.cargo("build").arg("--features").arg("foo"),
execs().with_status(0));
}
[features]
f3 = []
"#)
- .file("d3/src/lib.rs", "");
+ .file("d3/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("fetch"), execs().with_status(0));
+ assert_that(p.cargo("fetch"), execs().with_status(0));
let loc = p.root().join("Cargo.lock");
let mut lockfile = String::new();
t!(t!(File::open(&loc)).read_to_string(&mut lockfile));
default = ["f1"]
f1 = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
}
.file("a/src/lib.rs", r#"
#[cfg(feature = "f1")]
pub fn a() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
}
version = "0.1.0"
authors = []
"#)
- .file("foo/src/lib.rs", "");
+ .file("foo/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[COMPILING] test v0.1.0 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
.file("foo/src/lib.rs", r#"
#[cfg(feature = "a")]
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("a").arg("-v"),
+ assert_that(p.cargo("build").arg("--features").arg("a").arg("-v"),
execs().with_status(0));
}
.file("bar/src/lib.rs", r#"
#[cfg(feature = "some-feat")]
pub fn test() { print!("test"); }
- "#);
- p.build();
+ "#)
+ .build();
// The foo project requires that feature "some-feat" in "bar" is enabled.
// Building without any features enabled should fail:
version = "0.0.1"
authors = []
"#)
- .file("baz/src/lib.rs", "pub fn baz() {}");
+ .file("baz/src/lib.rs", "pub fn baz() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--all-features"),
+ assert_that(p.cargo("build").arg("--all-features"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("baz/src/lib.rs", "pub fn baz() {}");
+ .file("baz/src/lib.rs", "pub fn baz() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("bar,baz"),
+ assert_that(p.cargo("build").arg("--features").arg("bar,baz"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
version = "0.0.1"
authors = []
"#)
- .file("bap/src/lib.rs", "pub fn bap() {}");
+ .file("bap/src/lib.rs", "pub fn bap() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--features").arg("bar,baz bam bap"),
+ assert_that(p.cargo("build").arg("--features").arg("bar,baz bam bap"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
[COMPILING] ba[..] v0.0.1 ({dir}/ba[..])
.file("src/main.rs", r#"
mod a; fn main() {}
"#)
- .file("src/a.rs", "");
+ .file("src/a.rs", "")
+ .build();
- assert_that(p.cargo_process("fetch"),
+ assert_that(p.cargo("fetch"),
execs().with_status(0).with_stdout(""));
}
.file("src/main.rs", r#"
mod a; fn main() {}
"#)
- .file("src/a.rs", "");
+ .file("src/a.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
fn main() {}
"#)
.file("src/b.rs", "")
- .file("tests/test.rs", "");
+ .file("tests/test.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
authors = []
version = "0.0.1"
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
File::create(&p.root().join("b/src/lib.rs")).unwrap().write_all(br#"
[features]
foo = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
[..]Compiling foo v0.0.1 ([..])
[profile.test]
panic = "unwind"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
[..]Compiling foo v0.0.1 ([..])
fn main() {
yo();
}
- "#);
+ "#)
+ .build();
/* Build and rebuild a/. Ensure dep_crate only builds once */
- assert_that(p.cargo_process("run").cwd(p.root().join("a")),
+ assert_that(p.cargo("run").cwd(p.root().join("a")),
execs().with_status(0)
.with_stdout("ftest off")
.with_stderr("\
let msg = if cfg!(feature = "foo") { "feature on" } else { "feature off" };
println!("{}", msg);
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(0)
.with_stdout("feature off")
.with_stderr("\
extern crate foo;
#[test]
fn test() { foo::foo(); }
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
version = "0.0.1"
authors = []
"#)
- .file("c/src/lib.rs", "");
+ .file("c/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("test").arg("--no-run"),
execs().with_status(0)
println!("cargo:rerun-if-changed=build.rs");
}
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("build"),
execs().with_status(0).with_stdout(""));
.file(".cargo/config", r#"
[build]
target-dir = "./target"
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").cwd(p.root().join("a1")),
execs().with_status(0).with_stderr(&format!("\
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
p.root().move_into_the_past();
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
p.root().move_into_the_future();
fn main() {
println!("{}", env!("CARGO_PKG_DESCRIPTION"));
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(0)
.with_stdout("old desc").with_stderr(&format!("\
[COMPILING] env_change v0.0.1 ({dir})
authors = []
version = "0.0.1"
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"),
+ assert_that(p.cargo("generate-lockfile"),
execs().with_status(0));
let toml = p.root().join("Cargo.toml");
authors = []
version = "0.0.1"
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"),
+ assert_that(p.cargo("generate-lockfile"),
execs().with_status(0));
let metadata = r#"
authors = []
version = "0.0.1"
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
let lockfile = p.root().join("Cargo.lock");
- assert_that(p.cargo_process("generate-lockfile"),
+ assert_that(p.cargo("generate-lockfile"),
execs().with_status(0));
assert_that(&lockfile,
existing_file());
authors = []
version = "0.0.1"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
let lockfile = p.root().join("Cargo.lock");
assert_that(&lockfile, is_not(existing_file()));
- assert_that(p.cargo_process("update"), execs().with_status(0).with_stdout(""));
+ assert_that(p.cargo("update"), execs().with_status(0).with_stdout(""));
assert_that(&lockfile, existing_file());
fs::remove_file(p.root().join("Cargo.lock")).unwrap();
git = '{}'
"#, git_project.url()))
- .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
[COMPILING] dep1 v0.5.0 ({}#[..])\n\
branch = "branchy"
"#, git_project.url()))
- .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
[COMPILING] dep1 v0.5.0 ({}?branch=branchy#[..])\n\
git = '{}'
tag = "v0.1.0"
"#, git_project.url()))
- .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
let root = project.root();
let git_root = git_project.root();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
[COMPILING] dep1 v0.5.0 ({}?tag=v0.1.0#[..])\n\
name = "parent"
"#, git_project.url()))
.file("src/parent.rs",
- &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
name = "parent"
"#, git_project.url()))
.file("src/parent.rs",
- &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
name = "parent"
"#, git_project.url(), git_project.url()))
.file("src/parent.rs",
- &main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, &["dep1", "dep2"]));
+ &main_file(r#""{} {}", dep1::hello(), dep2::hello()"#, &["dep1", "dep2"]))
+ .build();
- p.cargo_process("build")
+ p.cargo("build")
.exec_with_output()
.unwrap();
name = "foo"
"#, url))
- .file("src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ .file("src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs()
.with_stdout("")
.with_stderr(&format!("\
assert_eq!(bar::bar(), 1);
assert_eq!(baz::baz(), 2);
}
- "#);
+ "#)
+ .build();
- let baz = project("baz")
+ let _baz = project("baz")
.file("Cargo.toml", &format!(r#"
[package]
name = "baz"
.file("src/lib.rs", r#"
extern crate bar;
pub fn baz() -> i32 { bar::bar() }
- "#);
-
- baz.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(foo.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(&foo.bin("foo"), existing_file());
assert_that(foo.process(&foo.bin("foo")), execs().with_status(0));
git = '{}'
"#, git_project.url()))
.file("src/main.rs",
- &main_file(r#""{:?}", bar::bar()"#, &["bar"]));
+ &main_file(r#""{:?}", bar::bar()"#, &["bar"]))
+ .build();
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[UPDATING] git repository `{}`\n\
[COMPILING] bar v0.5.0 ({}#[..])\n\
[COMPILING] foo v0.5.0 ({})\n\
version = "0.5.0"
git = '{}'
"#, git_project.url()))
- .file("dep2/src/lib.rs", "");
+ .file("dep2/src/lib.rs", "")
+ .build();
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("\
[UPDATING] git repository `{git}`
[COMPILING] bar v0.5.0 ({git}#[..])
.file("src/lib.rs", "
extern crate dep1;
pub fn foo() { dep1::dep() }
- ");
+ ")
+ .build();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs().with_stderr("\
[UPDATING] git repository [..]
[COMPILING] dep1 [..]
Some("something something"),
None).unwrap();
- let project = project
+ let p = project
.file("Cargo.toml", &format!(r#"
[project]
.file("src/lib.rs", "
extern crate dep1;
pub fn foo() { dep1::dep() }
- ");
+ ")
+ .build();
let expected = format!("\
[UPDATING] git repository [..]
To learn more, run the command again with --verbose.\n", path2url(git_project.root()));
- assert_that(project.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(expected).with_status(101));
}
.file("src/lib.rs", "")
}).unwrap();
- let project = project
+ let p = project
.file("Cargo.toml", &format!(r#"
[project]
[dependencies.dep2]
git = '{}'
"#, git1.url(), git2.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(project.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `[..]`\n\
[UPDATING] git repository `[..]`\n\
[COMPILING] [..] v0.5.0 ([..])\n\
[COMPILING] foo v0.5.0 ({})\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n",
- project.url())));
+ p.url())));
File::create(&git1.root().join("src/lib.rs")).unwrap().write_all(br#"
pub fn foo() {}
git::add(&repo);
git::commit(&repo);
- assert_that(project.cargo("update")
+ assert_that(p.cargo("update")
.arg("-p").arg("dep1"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
extern crate bar;
fn main() { assert_eq!(bar::bar(), 1) }
- "#);
+ "#)
+ .build();
- assert_that(foo.cargo_process("build"), execs().with_status(0));
+ assert_that(foo.cargo("build"), execs().with_status(0));
assert_that(foo.process(&foo.bin("foo")), execs().with_status(0));
// Update the repo, and simulate someone else updating the lockfile and then
Path::new("src"));
git::commit(&repo);
- let project = project
+ let p = project
.file("Cargo.toml", &format!(r#"
[project]
name = "foo"
.file("src/main.rs", "
extern crate dep1;
pub fn main() { println!(\"{}\", dep1::dep()) }
- ");
+ ")
+ .build();
println!("first run");
- assert_that(project.cargo_process("run"), execs()
+ assert_that(p.cargo("run"), execs()
.with_stderr("[UPDATING] git repository `[..]`\n\
[COMPILING] dep1 v0.5.0 ([..])\n\
[COMPILING] foo v0.5.0 ([..])\n\
sleep_ms(1000);
// Update the dependency and carry on!
println!("update");
- assert_that(project.cargo("update").arg("-v"),
+ assert_that(p.cargo("update").arg("-v"),
execs()
.with_stderr("")
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
", git_project.url())));
println!("last run");
- assert_that(project.cargo("run"), execs()
+ assert_that(p.cargo("run"), execs()
.with_stderr("[COMPILING] dep1 v0.5.0 ([..])\n\
[COMPILING] foo v0.5.0 ([..])\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) in \
extern crate bar;
#[test] fn foo() { bar::gimme(); }
}
- "#);
+ "#)
+ .build();
// Generate a lockfile which did not use `bar` to compile, but had to update
// `bar` to generate the lockfile
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("\
[UPDATING] git repository `{bar}`
[COMPILING] foo v0.5.0 ({url})
[dev-dependencies.bar]
git = '{}'
"#, p2.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
// Generate a lockfile which did not use `bar` to compile, but had to update
// `bar` to generate the lockfile
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("\
[UPDATING] git repository `{bar}`
[COMPILING] foo v0.5.0 ({url})
git = '{}'
"#, bar.url()))
.file("src/main.rs", "fn main() {}")
- .file("build.rs", "fn main() {}");
- p1.build();
+ .file("build.rs", "fn main() {}")
+ .build();
p1.root().move_into_the_past();
assert_that(p1.cargo("build"),
execs().with_stderr(&format!("\
[dependencies.bar]
git = '{}'
"#, bar.url()))
- .file("src/main.rs", "fn main() {}");
- assert_that(p2.cargo_process("build"),
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p2.cargo("build"),
execs().with_stderr(&format!("\
[UPDATING] git repository `{bar}`
[COMPILING] [..]
[dependencies.bar]
git = '{}'
"#, bar.url()))
- .file("src/main.rs", "fn main() {}");
- assert_that(p.cargo_process("fetch"),
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("fetch"),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] git repository `{url}`
", url = bar.url())));
[dependencies.bar]
git = '{}'
"#, bar.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
[COMPILING] bar v0.5.0 ({}#[..])\n\
[dependencies.bar]
git = '{}'
"#, foo1.url(), bar.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"), execs().with_status(0));
+ assert_that(p.cargo("generate-lockfile"), execs().with_status(0));
assert_that(p.cargo("update")
.arg("-p").arg("foo"),
execs().with_status(101)
[dependencies.a]
git = '{}'
"#, foo.url(), foo.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"), execs().with_status(0));
+ assert_that(p.cargo("generate-lockfile"), execs().with_status(0));
assert_that(p.cargo("update")
.arg("-p").arg("foo"),
execs().with_status(0)
[dependencies.dep]
git = '{}'
"#, dep1.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- p.build();
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr(&format!("\
[dependencies.dep]
git = '{}'
"#, dep.url()))
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
[dependencies.a]
git = '{}'
"#, a1.url()))
- .file("b/src/lib.rs", "pub fn main() {}");
+ .file("b/src/lib.rs", "pub fn main() {}")
+ .build();
- p.build();
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
#[test]
fn dont_require_submodules_are_checked_out() {
- let project = project("foo");
+ let p = project("foo").build();
let git1 = git::new("dep1", |p| {
p.file("Cargo.toml", r#"
[project]
git::add_submodule(&repo, &url, Path::new("a/submodule"));
git::commit(&repo);
- git2::Repository::init(&project.root()).unwrap();
+ git2::Repository::init(&p.root()).unwrap();
let url = path2url(git1.root()).to_string();
let dst = paths::home().join("foo");
git2::Repository::clone(&url, &dst).unwrap();
.file("src/lib.rs", r#"
#[macro_use]
extern crate a;
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
[dependencies]
a = {{ git = '{}' }}
"#, a.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] git repository `[..]`
[COMPILING] a v0.5.0 ([..])
[dependencies]
a = {{ git = '{}' }}
"#, a.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] git repository `[..]`
[COMPILING] a v0.5.0 ([..])
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
File::create(p.root().join("a/Cargo.toml")).unwrap().write_all(format!(r#"
[package]
git1 = {{ git = '{0}', rev = 'v0.1.0' }}
git2 = {{ git = '{0}', rev = 'v0.1.0' }}
"#, git.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"), execs().with_status(0));
+ assert_that(p.cargo("generate-lockfile"), execs().with_status(0));
assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
}
git = '{}'
"#, git_project.url()))
- .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]));
+ .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]))
+ .build();
let git_root = git_project.root();
- assert_that(project.cargo_process("build"),
+ assert_that(project.cargo("build"),
execs()
.with_stderr(&format!("[UPDATING] git repository `{}`\n\
error: failed to load source for a dependency on `dep1`\n\
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("a/src/main.rs", "fn main() {}");
- p.build();
+ .file("a/src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
execs().with_status(101).with_stderr("\
version = "0.1.0"
authors = []
"#)
- .file("a/src/main.rs", "fn main() {}");
- p.build();
+ .file("a/src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string())
.arg("foo"),
version = "0.1.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root())
.arg("--example=foo"),
version = "0.1.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(101).with_stderr("\
authors = []
"#)
.file("src/lib.rs", "")
- .file("examples/foo.rs", "fn main() {}");
- p.build();
+ .file("examples/foo.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()).arg("foo"),
execs().with_status(101).with_stderr("\
authors = []
"#)
.file("src/lib.rs", "")
- .file("examples/foo.rs", "extern crate foo; fn main() {}");
- p.build();
+ .file("examples/foo.rs", "extern crate foo; fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root())
.arg("--example=foo"),
authors = []
"#)
.file("src/bin/foo-bin1.rs", "fn main() {}")
- .file("src/bin/foo-bin2.rs", "fn main() {}");
- p.build();
+ .file("src/bin/foo-bin2.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
version = "0.2.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--force").arg("--path").arg(p.root()),
execs().with_status(0).with_stderr(&format!("\
authors = []
"#)
.file("src/bin/foo-bin1.rs", "fn main() {}")
- .file("src/bin/foo-bin2.rs", "fn main() {}");
- p.build();
+ .file("src/bin/foo-bin2.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
authors = []
"#)
.file("src/bin/foo-bin2.rs", "fn main() {}")
- .file("src/bin/foo-bin3.rs", "fn main() {}");
- p.build();
+ .file("src/bin/foo-bin3.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--force").arg("--path").arg(p.root()),
execs().with_status(0).with_stderr(&format!("\
authors = []
"#)
.file("src/bin/foo-bin1.rs", "fn main() {}")
- .file("src/bin/foo-bin2.rs", "fn main() {}");
- p.build();
+ .file("src/bin/foo-bin2.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
authors = []
"#)
.file("src/bin/foo-bin1.rs", "fn main() {}")
- .file("src/bin/foo-bin2.rs", "fn main() {}");
- p.build();
+ .file("src/bin/foo-bin2.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--force")
.arg("--bin")
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "");
- p.build();
+ .file("src/main.rs", "")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(101).with_stderr_contains("\
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
// use `--locked` to test that we don't even try to write a lockfile
assert_that(cargo_process("install").arg("--locked").arg("--git").arg(p.url().to_string()),
authors = []
"#)
.file("src/bin/foo.rs", "fn main() {}")
- .file("src/bin/bar.rs", "fn main() {}");
- p.build();
+ .file("src/bin/bar.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").cwd(p.root()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("--release"),
+ assert_that(p.cargo("build").arg("--release"),
execs().with_status(0));
assert_that(cargo_process("install").arg("--path").arg(p.root()),
execs().with_status(0).with_stderr("[INSTALLING] [..]
[[package]]
name = "bar"
version = "0.1.0"
- "#);
- p.build();
+ "#)
+ .build();
assert_that(cargo_process("install").arg("--git").arg(p.url().to_string()),
execs().with_status(0));
version = "0.1.0"
authors = []
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(cargo_process("install").arg("-q").arg("--path").arg(p.root()),
execs().with_status(0).with_stderr(""));
[dependencies]
foo = "1"
"#)
- .file("baz/src/lib.rs", "");
- p.build();
+ .file("baz/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"), execs().with_status(0));
let lock = p.read_lockfile();
// a little too complicated for a test...
}
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
let mut v = Vec::new();
stream.read_to_end(&mut v).unwrap();
}
- "#)
- .file("Makefile", "\
+ "#)
+ .file("Makefile", "\
all:
\t+$(CARGO) build
-");
- p.build();
+")
+ .build();
let l = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = l.local_addr().unwrap();
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "")
- .file("Makefile", "\
+ .file("src/lib.rs", "")
+ .file("Makefile", "\
all:
\t+$(CARGO) build -j2
-");
- p.build();
+")
+ .build();
assert_that(p.process(make)
.env("CARGO", cargo_exe())
pub fn bar() {
foo::foo();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] foo v0.0.1 ([..])
[COMPILING] foo v0.0.1
pub fn bar() {
foo::foo();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] foo v0.1.0 ([..])
[COMPILING] foo v0.1.0
foo::foo();
bar::bar();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] [..]
[UNPACKING] [..]
foo::foo();
bar::bar();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] [..]
[UNPACKING] [..]
foo::foo();
bar::bar();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] [..]
[UNPACKING] [..]
[source.my-awesome-local-directory]
local-registry = '/path/to/nowhere'
- "#);
-
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[ERROR] failed to load source for a dependency on `foo`
[dependencies]
foo = "*"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
// Generate a lock file against the crates.io registry
Package::new("foo", "0.0.1").publish();
pub fn bar() {
foo::foo();
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UNPACKING] foo v0.0.1 ([..])
[COMPILING] foo v0.0.1
.file("src/lib.rs", "")
.file("Cargo.lock", old_lockfile);
- p.build();
+ let p = p.build();
assert_that(p.cargo(cargo_command),
execs().with_status(0));
"checksum foo 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "checksum"
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
"checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "checksum"
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[metadata]
"checksum foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "<none>"
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("fetch"),
execs().with_status(101).with_stderr("\
"checksum foo 0.1.0 (git+{0})" = "checksum"
"#, git.url()));
- p.build();
+ let p = p.build();
assert_that(p.cargo("fetch"),
execs().with_status(101).with_stderr("\
foo = "0.1.0"
"#)
.file("src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
.file("src/lib.rs", "")
.file("Cargo.lock", lockfile);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
foo = "0.1.0"
"#)
.file("src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").arg("--locked"),
execs().with_status(101).with_stderr("\
#[test]
fn cargo_metadata_simple() {
let p = project("foo")
- .file("src/foo.rs", "")
- .file("Cargo.toml", &basic_bin_manifest("foo"));
+ .file("src/foo.rs", "")
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .build();
- assert_that(p.cargo_process("metadata"), execs().with_json(r#"
+ assert_that(p.cargo("metadata"), execs().with_json(r#"
{
"packages": [
{
fn cargo_metadata_warns_on_implicit_version() {
let p = project("foo")
.file("src/foo.rs", "")
- .file("Cargo.toml", &basic_bin_manifest("foo"));
- p.build();
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .build();
assert_that(p.cargo("metadata"),
execs().with_stderr("\
#[test]
fn library_with_several_crate_types() {
let p = project("foo")
- .file("src/lib.rs", "")
- .file("Cargo.toml", r#"
+ .file("src/lib.rs", "")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.5.0"
[lib]
crate-type = ["lib", "staticlib"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("metadata"), execs().with_json(r#"
+ assert_that(p.cargo("metadata"), execs().with_json(r#"
{
"packages": [
{
[dependencies]
bar = "*"
- "#);
+ "#)
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("bar", "0.0.1").dep("baz", "0.0.1").publish();
- assert_that(p.cargo_process("metadata")
+ assert_that(p.cargo("metadata")
.arg("-q")
.arg("--format-version").arg("1"),
execs().with_json(r#"
#[test]
fn example() {
let p = project("foo")
- .file("src/lib.rs", "")
- .file("examples/ex.rs", "")
- .file("Cargo.toml", r#"
+ .file("src/lib.rs", "")
+ .file("examples/ex.rs", "")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
[[example]]
name = "ex"
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("metadata"), execs().with_json(r#"
+ assert_that(p.cargo("metadata"), execs().with_json(r#"
{
"packages": [
{
#[test]
fn example_lib() {
let p = project("foo")
- .file("src/lib.rs", "")
- .file("examples/ex.rs", "")
- .file("Cargo.toml", r#"
+ .file("src/lib.rs", "")
+ .file("examples/ex.rs", "")
+ .file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
[[example]]
name = "ex"
crate-type = ["rlib", "dylib"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("metadata"), execs().with_json(r#"
+ assert_that(p.cargo("metadata"), execs().with_json(r#"
{
"packages": [
{
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
.file("bar/src/lib.rs", "")
.file("baz/Cargo.toml", &basic_lib_manifest("baz"))
- .file("baz/src/lib.rs", "");
+ .file("baz/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("metadata"), execs().with_status(0).with_json(r#"
+ assert_that(p.cargo("metadata"), execs().with_status(0).with_json(r#"
{
"packages": [
{
.file("bar/Cargo.toml", &basic_lib_manifest("bar"))
.file("bar/src/lib.rs", "")
.file("baz/Cargo.toml", &basic_lib_manifest("baz"))
- .file("baz/src/lib.rs", "");
+ .file("baz/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps"), execs().with_status(0).with_json(r#"
+ assert_that(p.cargo("metadata").arg("--no-deps"), execs().with_status(0).with_json(r#"
{
"packages": [
{
#[test]
fn cargo_metadata_with_invalid_manifest() {
let p = project("foo")
- .file("Cargo.toml", "");
+ .file("Cargo.toml", "")
+ .build();
- assert_that(p.cargo_process("metadata").arg("--format-version").arg("1"),
+ assert_that(p.cargo("metadata").arg("--format-version").arg("1"),
execs().with_status(101).with_stderr("\
[ERROR] failed to parse manifest at `[..]`
fn cargo_metadata_no_deps_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--manifest-path").arg("foo/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_metadata_no_deps_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--manifest-path").arg(p.root().join("Cargo.toml"))
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_metadata_no_deps_path_to_cargo_toml_parent_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--manifest-path").arg("foo")
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--manifest-path").arg(p.root())
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn cargo_metadata_no_deps_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.cwd(p.root()),
execs().with_status(0)
.with_json(MANIFEST_OUTPUT));
fn cargo_metadata_bad_version() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("metadata").arg("--no-deps")
+ assert_that(p.cargo("metadata").arg("--no-deps")
.arg("--format-version").arg("2")
.cwd(p.root()),
execs().with_status(101)
a = []
b = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("metadata")
+ assert_that(p.cargo("metadata")
.arg("--features").arg("a b"),
execs().with_status(0));
}
retry=1
[http]
timeout=1
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101)
.with_stderr_contains("[WARNING] spurious network error \
(1 tries remaining): [..]"));
[http]
timeout=1
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("build").arg("-v").arg("-j").arg("1"),
+ assert_that(p.cargo("build").arg("-v").arg("-j").arg("1"),
execs().with_status(101)
.with_stderr_contains("[WARNING] spurious network error \
(2 tries remaining): [..]")
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
pub fn bar() {
foo::foo();
}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[UPDATING] git repository `[..]`
[replace]
foo = { git = 'https://example.com' }
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
[replace]
"foo:*" = { git = 'https://example.com' }
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr_contains("\
error: failed to parse manifest at `[..]`
[replace]
"foo:0.1.0" = "0.2.0"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"foo:0.1.0" = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[UPDATING] git repository `[..]`
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
pub fn bar() {
foo::foo();
}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[UPDATING] git repository `file://[..]`
fn replace_registry_with_path() {
Package::new("foo", "0.1.0").publish();
- project("foo")
+ let _ = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
pub fn bar() {
foo::foo();
}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.1.0 (file://[..])
version = "0.2.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo3() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo3() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
foo::foo1();
bar::bar();
}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[UPDATING] git repository `[..]`
[dependencies]
foo = "0.1"
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"bar:0.1.0" = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[UPDATING] git repository `[..]`
[dependencies]
foo = "*"
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"bar:0.1.0" = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("build"), execs().with_status(0).with_stdout(""));
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"foo:0.1.0" = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[UPDATING] git repository [..]
Package::new("foo", "0.1.0").publish();
let foo = git::repo(&paths::root().join("override"))
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"foo:0.1.0" = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[UPDATING] git repository [..]
[replace]
"foo:0.1.0" = { git = 'https://example.com', version = '0.2.0' }
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
error: failed to parse manifest at `[..]`
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace."https://github.com/rust-lang/crates.io-index#foo:0.1.0"]
git = '{0}'
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[UPDATING] git repository [..]
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"foo:0.1.0" = {{ git = '{0}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-p").arg("foo"),
+ assert_that(p.cargo("test").arg("-p").arg("foo"),
execs().with_status(101)
.with_stderr_contains("\
error: There are multiple `foo` packages in your project, and the [..]
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
[replace]
"foo:0.1.0" = {{ git = '{0}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("generate-lockfile"),
+ assert_that(p.cargo("generate-lockfile"),
execs().with_status(0));
assert_that(p.cargo("update"),
execs().with_status(0)
.file("near/src/lib.rs", r#"
#![no_std]
pub extern crate far;
- "#);
-
- deps.build();
+ "#)
+ .build();
let p = project("local")
.file("Cargo.toml", &format!(r#"
.file("src/lib.rs", r#"
#![no_std]
pub extern crate near;
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build").arg("--verbose"),
+ assert_that(p.cargo("build").arg("--verbose"),
execs().with_status(0));
}
.file("a2/src/lib.rs", "")
.file(".cargo/config", r#"
paths = ["a2"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
[UPDATING] [..]
"#)
.file("serde/src/lib.rs", "
pub fn serde08_override() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
version = "0.1.0"
authors = []
"#)
- .file("bar/src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("bar/src/lib.rs", "pub fn foo() {}")
+ .build();
let p = project("local")
"foo:0.1.0" = {{ git = '{url}' }}
"bar:0.1.0" = {{ git = '{url}' }}
"#, url = foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
name = "foo"
version = "0.1.0"
"#)
- .file("local_foo/src/lib.rs", "");
- p.build();
+ .file("local_foo/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").cwd(p.root().join("first_crate")),
execs().with_status(0)
.file("foo/bar/src/lib.rs", "")
.file(".cargo/config", r#"
paths = ["foo"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
version = "0.1.0"
authors = []
"#)
- .file("foo/bar/src/lib.rs", "pub fn bar() {}");
+ .file("foo/bar/src/lib.rs", "pub fn bar() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
.file("foo2/src/lib.rs", "")
.file(".cargo/config", r#"
paths = ["foo2"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.1.0 ([..]foo2)
[COMPILING] local v0.0.1 ([..])
.file("foo2/src/lib.rs", "")
.file(".cargo/config", r#"
paths = ["foo2"]
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr_contains("\
warning: path override for crate `foo` has altered the original list of
dependencies; the dependency on `bar` was either added or\
[dependencies]
bar = { version = "0.1", default-features = false }
"#)
- .file("another2/src/lib.rs", "");
+ .file("another2/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(0));
}
[dependencies]
foo = { path = ".." }
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr_contains("\
error: cyclic package dependency: [..]
"));
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#)
- .file("src/bar.txt", ""); // should be ignored when packaging
+ .file("src/bar.txt", "") // should be ignored when packaging
+ .build();
- assert_that(p.cargo_process("package"),
+ assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
[WARNING] manifest has no documentation[..]
See [..]
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- assert_that(p.cargo_process("package"),
+ "#)
+ .build();
+ assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
warning: manifest has no description, license, license-file, documentation, \
homepage or repository.
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- assert_that(p.cargo_process("package"),
+ "#)
+ .build();
+ assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
warning: manifest has no description, documentation, homepage or repository.
See http://doc.crates.io/manifest.html#package-metadata for more info.
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- assert_that(p.cargo_process("package"),
+ "#)
+ .build();
+ assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
[PACKAGING] foo v0.0.1 ({dir})
[VERIFYING] foo v0.0.1 ({dir})
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
let mut cargo = cargo_process();
cargo.cwd(p.root());
assert_that(cargo.clone().arg("build"), execs().with_status(0));
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("package"),
+ assert_that(p.cargo("package"),
execs().with_status(101).with_stderr("\
[WARNING] manifest has no documentation, homepage or repository.
See http://doc.crates.io/manifest.html#package-metadata for more info.
.file("some_dir/dir_deep_3/some_dir/file", "")
.file("some_dir/dir_deep_4/some_dir/file", "")
.file("some_dir/dir_deep_5/some_dir/file", "")
- ;
+ .build();
- assert_that(p.cargo_process("package").arg("--no-verify").arg("-v"),
+ assert_that(p.cargo("package").arg("--no-verify").arg("-v"),
execs().with_status(0).with_stdout("").with_stderr("\
[WARNING] manifest has no description[..]
See http://doc.crates.io/manifest.html#package-metadata for more info.
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#)
- .file("src/bar.txt", ""); // should be ignored when packaging
+ .file("src/bar.txt", "") // should be ignored when packaging
+ .build();
- assert_that(p.cargo_process("package").arg("--no-verify").arg("-v"),
+ assert_that(p.cargo("package").arg("--no-verify").arg("-v"),
execs().with_status(0).with_stderr("\
[WARNING] manifest has no description[..]
See http://doc.crates.io/manifest.html#package-metadata for more info.
extern crate foo;
fn main() {}
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("package").arg("-v"),
+ assert_that(p.cargo("package").arg("-v"),
execs().with_status(0));
}
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- p.build();
+ "#)
+ .build();
File::create(p.root().join("src/main.rs")).unwrap().write_all(br#"
fn main() { println!("A change!"); }
"#).unwrap();
// If a project happens to contain a copy of itself, we should
// ignore it.
.file("a_dir/nested/Cargo.toml", cargo_toml)
- .file("a_dir/nested/src/main.rs", main_rs);
+ .file("a_dir/nested/src/main.rs", main_rs)
+ .build();
- assert_that(p.cargo_process("package"),
+ assert_that(p.cargo("package"),
execs().with_status(0).with_stderr(&format!("\
[WARNING] manifest has no documentation[..]
See http://doc.crates.io/manifest.html#package-metadata for more info.
.file("src/main.rs", r#"
fn main() { println!("hello"); }
"#)
- .file("src/:foo", "");
+ .file("src/:foo", "")
+ .build();
- assert_that(p.cargo_process("package"),
+ assert_that(p.cargo("package"),
execs().with_status(101).with_stderr("\
warning: [..]
See [..]
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("package"),
+ assert_that(p.cargo("package"),
execs().with_status(0));
// Add another source file
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
- p.build();
+ "#)
+ .build();
t!(fs::symlink("nowhere", &p.root().join("src/foo.rs")));
assert_that(p.cargo("package").arg("-v"),
#[test]
fn do_not_package_if_repository_is_dirty() {
- let p = project("foo");
- p.build();
+ let p = project("foo").build();
// Create a Git repository containing a minimal Rust project.
- git::repo(&paths::root().join("foo"))
+ let _ = git::repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.1.0"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("package").arg("--no-verify"),
+ assert_that(p.cargo("package").arg("--no-verify"),
execs().with_status(0));
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
authors = []
workspace = ".."
"#)
- .file("bar/src/lib.rs", "");
- p.build();
+ .file("bar/src/lib.rs", "")
+ .build();
assert_that(p.cargo("package").arg("--no-verify").cwd(p.root().join("bar")),
execs().with_status(0));
other = "1.0"
other1 = { version = "1.0" }
"#)
- .file("src/main.rs", "");
+ .file("src/main.rs", "")
+ .build();
- assert_that(p.cargo_process("package").arg("--no-verify"),
+ assert_that(p.cargo("package").arg("--no-verify"),
execs().with_status(0));
}
"#)
.file("foo/src/lib.rs", r#"
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[DOWNLOADING] deep-foo v0.1.0 ([..])
"#)
.file("foo/src/lib.rs", r#"
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.1.0 (file://[..])
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("bar")
.file("Cargo.toml", &format!(r#"
"#)
.file("foo/src/lib.rs", r#"
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] git repository `file://[..]`
[COMPILING] foo v0.1.0 (file://[..])
version = "0.1.0"
authors = []
"#)
- .file("src/lib.rs", "pub fn foo() {}");
- foo.build();
+ .file("src/lib.rs", "pub fn foo() {}")
+ .build();
Package::new("foo", "0.1.0").publish();
pub fn bar() {
foo::foo();
}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("build"),//.env("RUST_LOG", "cargo=trace"),
+ assert_that(p.cargo("build"),//.env("RUST_LOG", "cargo=trace"),
execs().with_status(0).with_stderr("\
[UPDATING] git repository `file://[..]`
[UPDATING] registry `file://[..]`
"#)
.file("foo/src/lib.rs", r#"
not rust code
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[DOWNLOADING] foo v0.1.0 [..]
version = "0.2.0"
authors = []
"#)
- .file("src/lib.rs", "");
- foo.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("bar")
.file("Cargo.toml", &format!(r#"
[patch.crates-io]
foo = {{ git = '{}' }}
"#, foo.url()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] git repository `file://[..]`
[UPDATING] registry `file://[..]`
version = "0.1.0"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[DOWNLOADING] foo v0.1.0 [..]
version = "0.1.1"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[DOWNLOADING] foo v0.1.0 [..]
version = "0.1.1"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.1.1 [..]
version = "0.1.1"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.1.1 [..]
version = "0.2.0"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.2.0 [..]
version = "0.2.0"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
[UPDATING] registry `file://[..]`
[COMPILING] foo v0.2.0 [..]
version = "0.1.0"
authors = []
"#)
- .file("bar/src/lib.rs", r#""#);
+ .file("bar/src/lib.rs", r#""#)
+ .build();
// Generate a lock file where `bar` is unused
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
let mut lock_file1 = String::new();
File::open(p.root().join("Cargo.lock")).unwrap()
.read_to_string(&mut lock_file1).unwrap();
version = "0.1.0"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
error: failed to parse manifest at `[..]`
version = "0.1.0"
authors = []
"#)
- .file("foo/src/lib.rs", r#""#);
+ .file("foo/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[UPDATING] [..]
[dependencies]
foo = "0.1"
"#)
- .file("bar/src/lib.rs", r#""#);
+ .file("bar/src/lib.rs", r#""#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
assert_that(p.cargo("build"),
execs().with_status(0).with_stderr("\
pub fn gimme() -> String {
"test passed".to_string()
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr(&format!("[COMPILING] baz v0.5.0 ({}/bar/baz)\n\
[COMPILING] bar v0.5.0 ({}/bar)\n\
name = "foo"
"#)
.file("src/main.rs",
- &main_file(r#""{}", bar::gimme()"#, &["bar"]));
- let p2 = project("bar")
+ &main_file(r#""{}", bar::gimme()"#, &["bar"]))
+ .build();
+ let _p2 = project("bar")
.file("Cargo.toml", r#"
[package]
pub fn gimme() -> &'static str {
"zoidberg"
}
- "#);
+ "#)
+ .build();
- p2.build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101))
}
name = "foo"
"#)
.file("src/main.rs",
- &main_file(r#""{}", bar::gimme()"#, &["bar"]));
- let p2 = project("bar")
+ &main_file(r#""{}", bar::gimme()"#, &["bar"]))
+ .build();
+ let _p2 = project("bar")
.file("Cargo.toml", r#"
[package]
pub fn gimme() -> &'static str {
"zoidberg"
}
- "#);
+ "#)
+ .build();
- p2.build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_stderr("\
[COMPILING] [..] v0.5.0 ([..])
[COMPILING] [..] v0.5.0 ([..])
pub fn gimme() -> &'static str {
"zoidberg"
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] bar v0.5.0 ({}/bar)\n\
[COMPILING] foo v0.5.0 ({})\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) in \
"#)
.file("bar/src/bar.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
// First time around we should compile both foo and bar
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] bar v0.5.0 ({}/bar)\n\
[COMPILING] foo v0.5.0 ({})\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) \
#[test]
fn deep_dependencies_trigger_rebuild() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#)
.file("baz/src/baz.rs", r#"
pub fn baz() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] baz v0.5.0 ({}/baz)\n\
[COMPILING] bar v0.5.0 ({}/bar)\n\
[COMPILING] foo v0.5.0 ({})\n\
#[test]
fn no_rebuild_two_deps() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[project]
"#)
.file("baz/src/baz.rs", r#"
pub fn baz() {}
- "#);
- assert_that(p.cargo_process("build"),
+ "#)
+ .build();
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] baz v0.5.0 ({}/baz)\n\
[COMPILING] bar v0.5.0 ({}/bar)\n\
[COMPILING] foo v0.5.0 ({})\n\
name = "bar"
"#)
- .file("src/bar/src/bar.rs", "pub fn gimme() -> i32 { 92 }");
+ .file("src/bar/src/bar.rs", "pub fn gimme() -> i32 { 92 }")
+ .build();
let bar = p.url();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_stderr(&format!("[COMPILING] bar v0.5.0 ({}/src/bar)\n\
[COMPILING] foo v0.5.0 ({})\n\
[FINISHED] dev [unoptimized + debuginfo] target(s) \
path = "src/bar"
"#)
.file("src/lib.rs", "")
- .file("src/bar/not-a-manifest", "");
+ .file("src/bar/not-a-manifest", "")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to load source for a dependency on `bar`
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
fs::create_dir(&paths::root().join(".cargo")).unwrap();
File::create(&paths::root().join(".cargo/config")).unwrap()
[dependencies.bar]
path = '{}'
"#, bar.root().display()))
- .file("src/lib.rs", "");
- bar.build();
- assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"), execs().with_status(0));
}
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
let p = project("foo");
let root = p.root().clone();
"#, bar.root().display()))
.file("src/lib.rs", "")
- .file("src/main.rs", "fn main() {}");
-
- bar.build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("build"), execs().with_status(0));
}
#[test]
version = "0.5.0"
authors = []
"#)
- .file("p2/src/lib.rs", "");
+ .file("p2/src/lib.rs", "")
+ .build();
let p = project("foo")
.file(".cargo/config", &format!(r#"
path = '{}'
"#, bar.root().join("p2").display()))
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- bar.build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}
"#)
.file("bar/src/bar.rs.in", r#"
pub fn gimme() -> i32 { 0 }
- "#);
-
- p.build();
+ "#).build();
p.root().join("bar").move_into_the_past();
assert_that(p.cargo("build"),
version = "0.5.0"
authors = ["wycats@example.com"]
"#)
- .file("bar/src/lib.rs", "pub fn bar() {}");
- p.build();
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
assert_that(p.cargo("build")
.env("FOO", "bar"),
execs().with_status(0)
[dependencies]
a = { path = "../a" }
"#)
- .file("b/src/lib.rs", "");
- p.build();
+ .file("b/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0)
.with_stderr("\
.file("b/src/lib.rs", "")
.file("b/.cargo/config", r#"
paths = ["../a"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").cwd(p.root().join("b")),
execs().with_status(0)
.with_stderr("\
.file("src/lib.rs", "")
.file(".cargo/config", r#"
paths = ["../whoa-this-does-not-exist"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
[dependencies]
bar = "*"
"#)
- .file("foo/src/lib.rs", "");
- p.build();
+ .file("foo/src/lib.rs", "")
+ .build();
// Generate a lock file
assert_that(p.cargo("build"), execs().with_status(0));
version = "0.5.0"
authors = []
"#)
- .file("foo/src/lib.rs", "");
- p.build();
+ .file("foo/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"), execs().with_status(0));
#![plugin(bar)]
pub fn foo() {}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
pub fn foo(_reg: &mut Registry) {
println!("{}", baz::baz());
}
- "#);
- let baz = project("baz")
+ "#)
+ .build();
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[package]
name = "baz"
name = "baz"
crate_type = ["dylib"]
"#)
- .file("src/lib.rs", "pub fn baz() -> i32 { 1 }");
- bar.build();
- baz.build();
+ .file("src/lib.rs", "pub fn baz() -> i32 { 1 }")
+ .build();
- assert_that(foo.cargo_process("build"),
+ assert_that(foo.cargo("build"),
execs().with_status(0));
assert_that(foo.cargo("doc"),
execs().with_status(0));
.file("Cargo.toml", r#"
[workspace]
members = ["builder", "foo"]
- "#);
- workspace.build();
+ "#)
+ .build();
let build = project("ws/builder")
.file("Cargo.toml", r#"
.file("src/lib.rs", r#"
#[no_mangle]
pub extern fn foo() {}
- "#);
- build.build();
+ "#)
+ .build();
let foo = project("ws/foo")
.file("Cargo.toml", r#"
pub fn bar(_reg: &mut Registry) {
unsafe { foo() }
}
- "#);
- foo.build();
+ "#)
+ .build();
assert_that(build.cargo("build"),
execs().with_status(0));
"#)
.file("build.rs", "fn main() {}")
.file("src/lib.rs", "")
- .file("tests/it_works.rs", "");
+ .file("tests/it_works.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
"#)
.file("bar/src/lib.rs", r#"
pub fn bar() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
fn native_plugin_dependency_with_custom_ar_linker() {
let target = rustc_host();
- let foo = project("foo")
+ let _foo = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
[lib]
plugin = true
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
let bar = project("bar")
.file("Cargo.toml", r#"
[target.{}]
ar = "nonexistent-ar"
linker = "nonexistent-linker"
- "#, target));
+ "#, target))
+ .build();
- foo.build();
- assert_that(bar.cargo_process("build").arg("--verbose"),
+ assert_that(bar.cargo("build").arg("--verbose"),
execs().with_stderr_contains("\
[COMPILING] foo v0.0.1 ([..])
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
return
}
- let bar = project("bar")
+ let p = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
.file("foo/src/lib.rs", r#"
#![feature(rustc_private)]
extern crate syntax;
- "#);
+ "#)
+ .build();
- assert_that(bar.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
return
}
- let bar = project("top")
+ let p = project("top")
.file("Cargo.toml", r#"
[package]
name = "top"
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(bar.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0));
}
struct X;
fn main() {}
- "#);
- let noop = project("noop")
+ "#)
+ .build();
+ let _noop = project("noop")
.file("Cargo.toml", r#"
[package]
name = "noop"
pub fn noop(_input: TokenStream) -> TokenStream {
"".parse().unwrap()
}
- "#);
- noop.build();
+ "#)
+ .build();
- assert_that(client.cargo_process("build"),
+ assert_that(client.cargo("build"),
execs().with_status(0));
}
struct X;
fn main() {}
- "#);
- let noop = project("noop")
+ "#)
+ .build();
+ let _noop = project("noop")
.file("Cargo.toml", r#"
[package]
name = "noop"
pub fn noop(_input: TokenStream) -> TokenStream {
"".parse().unwrap()
}
- "#);
- noop.build();
+ "#)
+ .build();
- assert_that(client.cargo_process("build"),
+ assert_that(client.cargo("build"),
execs().with_status(0));
assert_that(client.cargo("build"),
execs().with_status(0));
assert!(x.impl_by_transmogrify());
println!("{:?}", x);
}
- "#);
- let transmogrify = project("transmogrify")
+ "#)
+ .build();
+ let _transmogrify = project("transmogrify")
.file("Cargo.toml", r#"
[package]
name = "transmogrify"
}
".parse().unwrap()
}
- "#);
- transmogrify.build();
+ "#)
+ .build();
- assert_that(client.cargo_process("build"),
+ assert_that(client.cargo("build"),
execs().with_status(0));
assert_that(client.cargo("run"),
execs().with_status(0).with_stdout("X { success: true }"));
pub fn questionable(input: TokenStream) -> TokenStream {
input
}
- "#);
+ "#)
+ .build();
let msg = " lib.plugin and lib.proc-macro cannot both be true";
- assert_that(questionable.cargo_process("build"),
+ assert_that(questionable.cargo("build"),
execs().with_status(101).with_stderr_contains(msg));
}
fn a() {
assert!(true);
}
-"#);
+"#)
+ .build();
- assert_that(foo.cargo_process("test"),
+ assert_that(foo.cargo("test"),
execs().with_status(0)
.with_stdout_contains("test a ... ok")
.with_stdout_contains_n("test [..] ... ok", 2));
#[test]
fn profile_overrides() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
debug = false
rpath = true
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
#[test]
fn opt_level_override_0() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
[profile.dev]
opt-level = 0
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
#[test]
fn debug_override_1() {
- let mut p = project("foo");
-
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "test"
[profile.dev]
debug = 1
"#)
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
}
fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", &format!(r#"
[package]
[profile.dev]
opt-level = {level}
"#, level = profile_level))
- .file("src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v"),
+ .file("src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] test v0.0.0 ({url})
[RUNNING] `rustc --crate-name test src[/]lib.rs --crate-type lib \
#[test]
fn top_level_overrides_deps() {
- let mut p = project("foo");
- p = p
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
crate_type = ["dylib", "rlib"]
"#)
- .file("foo/src/lib.rs", "");
- assert_that(p.cargo_process("build").arg("-v").arg("--release"),
+ .file("foo/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("build").arg("-v").arg("--release"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] foo v0.0.0 ({url}/foo)
[RUNNING] `rustc --crate-name foo foo[/]src[/]lib.rs \
[profile.dev]
opt-level = 1
"#)
- .file("bar/src/main.rs", "fn main() {}");
+ .file("bar/src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"),
+ assert_that(p.cargo("build").cwd(p.root().join("bar")).arg("-v"),
execs().with_status(0).with_stderr("\
[WARNING] profiles for the non root package will be ignored, specify profiles at the workspace root:
package: [..]
authors = []
workspace = ".."
"#)
- .file("bar/src/main.rs", "fn main() {}");
+ .file("bar/src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").cwd(p.root().join("bar")).arg("-v"),
+ assert_that(p.cargo("build").cwd(p.root().join("bar")).arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] bar v0.1.0 ([..])
[RUNNING] `rustc [..]`
license = "MIT"
description = "foo"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish").arg("--no-verify")
+ assert_that(p.cargo("publish").arg("--no-verify")
.arg("--index").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
license = "MIT"
description = "foo"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish").arg("--no-verify")
+ assert_that(p.cargo("publish").arg("--no-verify")
.arg("--host").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[WARNING] The flag '--host' is no longer valid.
license = "MIT"
description = "foo"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish").arg("--no-verify")
+ assert_that(p.cargo("publish").arg("--no-verify")
.arg("--index").arg(publish::registry().to_string())
.arg("--host").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[dependencies.foo]
git = "git://path/to/nowhere"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify")
+ assert_that(p.cargo("publish").arg("-v").arg("--no-verify")
.arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
+ .file("bar/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("publish")
+ assert_that(p.cargo("publish")
.arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
description = "foo"
publish = false
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish")
+ assert_that(p.cargo("publish")
.arg("--index").arg(publish::registry().to_string()),
execs().with_status(101).with_stderr("\
[ERROR] some crates cannot be published.
fn dont_publish_dirty() {
publish::setup();
let p = project("foo")
- .file("bar", "");
- p.build();
+ .file("bar", "")
+ .build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[project]
name = "foo"
fn publish_clean() {
publish::setup();
- let p = project("foo");
- p.build();
+ let p = project("foo").build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[project]
name = "foo"
publish::setup();
let p = project("foo")
- .file("baz", "");
- p.build();
+ .file("baz", "")
+ .build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.file("bar/Cargo.toml", r#"
[project]
name = "foo"
publish::setup();
let p = project("foo")
- .file("baz", "");
- p.build();
+ .file("baz", "")
+ .build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.file("Cargo.toml", r#"
[project]
name = "foo"
publish::setup();
let p = project("foo")
- .file("bar/baz", "");
- p.build();
+ .file("bar/baz", "")
+ .build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.file(".gitignore", "bar")
.nocommit_file("bar/Cargo.toml", r#"
[project]
publish::setup();
let p = project("foo")
- .file("baz", "");
- p.build();
+ .file("baz", "")
+ .build();
- repo(&paths::root().join("foo"))
+ let _ = repo(&paths::root().join("foo"))
.nocommit_file("Cargo.toml", r#"
[project]
name = "foo"
license = "MIT"
description = "foo"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("publish").arg("--dry-run")
+ assert_that(p.cargo("publish").arg("--dry-run")
.arg("--index").arg(publish::registry().to_string()),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `[..]`
fn cargo_read_manifest_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("read-manifest")
+ assert_that(p.cargo("read-manifest")
.arg("--manifest-path").arg("foo/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_read_manifest_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("read-manifest")
+ assert_that(p.cargo("read-manifest")
.arg("--manifest-path").arg(p.root().join("Cargo.toml"))
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_read_manifest_path_to_cargo_toml_parent_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("read-manifest")
+ assert_that(p.cargo("read-manifest")
.arg("--manifest-path").arg("foo")
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn cargo_read_manifest_path_to_cargo_toml_parent_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("read-manifest")
+ assert_that(p.cargo("read-manifest")
.arg("--manifest-path").arg(p.root())
.cwd(p.root().parent().unwrap()),
execs().with_status(101)
fn cargo_read_manifest_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("read-manifest")
+ assert_that(p.cargo("read-manifest")
.cwd(p.root()),
execs().with_status(0)
.with_json(MANIFEST_OUTPUT));
[dependencies]
bar = ">= 0.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.0.1").publish();
[dependencies]
bar = ">= 0.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("bar", "0.0.1").dep("baz", "*").publish();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(0).with_stderr(&format!("\
[UPDATING] registry `{reg}`
[DOWNLOADING] [..] v0.0.1 (registry file://[..])
[dependencies]
nonexistent = ">= 0.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[ERROR] no matching package named `nonexistent` found (required by `foo`)
[dependencies]
foo = ">= 1.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "0.0.1").publish();
Package::new("foo", "0.0.2").publish();
[dependencies]
bad-cksum = ">= 0.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
let pkg = Package::new("bad-cksum", "0.0.1");
pkg.publish();
t!(File::create(&pkg.archive_dst()));
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(101).with_stderr("\
[UPDATING] registry [..]
[DOWNLOADING] bad-cksum [..]
[dependencies]
notyet = ">= 0.0.0"
"#)
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build"),
+ assert_that(p.cargo("build"),
execs().with_status(101).with_stderr_contains("\
[ERROR] no matching package named `notyet` found (required by `foo`)
location searched: registry [..]
version = "0.0.1"
authors = []
"#)
- .file("notyet/src/lib.rs", "");
- p.build();
+ .file("notyet/src/lib.rs", "")
+ .build();
assert_that(p.cargo("package").arg("-v"),
execs().with_status(101).with_stderr_contains("\
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.0.1").publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("bar", "0.0.1").dep("baz", "*").publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("baz", "0.0.2").yanked(true).publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("baz", "0.0.2").yanked(true).publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.0.1").publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.0.1").publish();
assert_that(p.cargo("build"),
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
println!("0.0.1");
Package::new("bar", "0.0.1").publish();
[dependencies]
bar = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("baz", "0.0.1").publish();
Package::new("bar", "0.0.1").dev_dep("baz", "*").publish();
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- assert_that(p.cargo_process("publish")
+ "#)
+ .build();
+ assert_that(p.cargo("publish")
.arg("-v")
.arg("--index").arg(registry().to_string()),
execs().with_status(101)
[dependencies]
bar = "*"
"#)
- .file("a/src/lib.rs", "");
- p.build();
+ .file("a/src/lib.rs", "")
+ .build();
Package::new("bar", "0.0.1").publish();
[dependencies]
a = "0.0.1"
"#)
- .file("src/lib.rs", "");
- b.build();
+ .file("src/lib.rs", "")
+ .build();
let p = project("foo")
.file("Cargo.toml", &format!(r#"
[project]
[dependencies.b]
git = '{}'
"#, b.url()))
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("a", "0.0.1").publish();
[dependencies]
a = "0.1.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("a", "0.1.0").publish();
assert_that(p.cargo("build"),
execs().with_status(0));
[dependencies]
a = "0.1.1"
"#)
- .file("src/main.rs", "fn main() {}");
- assert_that(p2.cargo_process("build"),
+ .file("src/main.rs", "fn main() {}")
+ .build();
+ assert_that(p2.cargo("build"),
execs().with_status(0));
registry.rm_rf();
t!(fs::rename(&backup, ®istry));
[dependencies]
a = "0.1.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("a", "0.1.0").publish();
[dependencies]
a = "0.1.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("a", "0.1.0").dep("b", "*").publish();
Package::new("b", "0.1.0").publish();
[dependencies]
webdriver = "0.1"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("webdriver", "0.1.0").dep("hyper", "0.6").publish();
Package::new("hyper", "0.6.5").dep("openssl", "0.1")
b = "*"
c = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("a", "0.1.0").publish();
Package::new("b", "0.1.0").publish();
bar = "0.1"
baz = "0.1"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("bar", "0.1.0").publish();
Package::new("baz", "0.1.0")
[dependencies]
foo = "0.1"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foobar", "0.2.0").publish();
Package::new("foo", "0.1.0")
[dependencies]
foo = "1.2.3-alpha.0"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "1.2.3-alpha.0").publish();
[dependencies]
baz = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "0.1.0").publish();
Package::new("bar", "0.1.0").publish();
[dependencies]
foo = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "0.1.1")
.feature_dep("bar", "0.1", &["a", "b"])
[dependencies]
foo = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("foo", "0.1.0")
.file("src/lib.rs", "fn unused() {}")
[dependencies]
foo = "*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--frozen"),
execs().with_status(101).with_stderr("\
[dependencies]
remote = "0.3"
"#)
- .file("baz/src/lib.rs", "");
- p.build();
+ .file("baz/src/lib.rs", "")
+ .build();
Package::new("remote", "0.3.4").publish();
[dependencies]
remote = "0.3"
"#)
- .file("baz/src/lib.rs", "");
- p.build();
+ .file("baz/src/lib.rs", "")
+ .build();
Package::new("remote", "0.3.4").publish();
[dependencies]
remote = "0.2*"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("remote", "0.2.0").publish();
[dependencies]
remote = "0.3"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
Package::new("remote", "0.3.0")
.file("Cargo.toml", r#"
[dependencies]
bar = "0.3"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
[dependencies]
foo = "0.2"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("-vv"),
execs().with_status(0));
[dependencies]
foo = "0.2"
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("-vv"),
execs().with_status(101)
.file("src/lib.rs", r#"
#[cfg(feature = "a")]
pub fn foo() {}
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
name = "foo"
required-features = ["a"]
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--features").arg("a"),
execs().with_status(0));
required-features = ["a"]
"#)
.file("src/foo_1.rs", "fn main() {}")
- .file("src/foo_2.rs", "fn main() {}");
- p.build();
+ .file("src/foo_2.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
name = "foo"
required-features = ["a"]
"#)
- .file("examples/foo.rs", "fn main() {}");
- p.build();
+ .file("examples/foo.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--example=foo"),
execs().with_status(0));
name = "foo"
required-features = ["a"]
"#)
- .file("examples/foo.rs", "fn main() {}");
- p.build();
+ .file("examples/foo.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--example=foo").arg("--features").arg("a"),
execs().with_status(0));
required-features = ["a"]
"#)
.file("examples/foo_1.rs", "fn main() {}")
- .file("examples/foo_2.rs", "fn main() {}");
- p.build();
+ .file("examples/foo_2.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("build").arg("--example=foo_1"),
execs().with_status(101).with_stderr("\
name = "foo"
required-features = ["a"]
"#)
- .file("tests/foo.rs", "#[test]\nfn test() {}");
- p.build();
+ .file("tests/foo.rs", "#[test]\nfn test() {}")
+ .build();
assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
name = "foo"
required-features = ["a"]
"#)
- .file("tests/foo.rs", "#[test]\nfn test() {}");
- p.build();
+ .file("tests/foo.rs", "#[test]\nfn test() {}")
+ .build();
assert_that(p.cargo("test").arg("--features").arg("a"),
execs().with_status(0).with_stderr(format!("\
required-features = ["a"]
"#)
.file("tests/foo_1.rs", "#[test]\nfn test() {}")
- .file("tests/foo_2.rs", "#[test]\nfn test() {}");
- p.build();
+ .file("tests/foo_2.rs", "#[test]\nfn test() {}")
+ .build();
assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
#[bench]
fn bench(_: &mut test::Bencher) {
- }"#);
- p.build();
+ }"#)
+ .build();
assert_that(p.cargo("bench"),
execs().with_status(0).with_stderr(format!("\
#[bench]
fn bench(_: &mut test::Bencher) {
- }"#);
- p.build();
+ }"#)
+ .build();
assert_that(p.cargo("bench").arg("--features").arg("a"),
execs().with_status(0).with_stderr(format!("\
#[bench]
fn bench(_: &mut test::Bencher) {
- }"#);
- p.build();
+ }"#)
+ .build();
assert_that(p.cargo("bench"),
execs().with_status(0).with_stderr(format!("\
required-features = ["a"]
"#)
.file("src/main.rs", "fn main() {}")
- .file("examples/foo.rs", "fn main() {}");
- p.build();
+ .file("examples/foo.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("install"),
execs().with_status(0));
name = "foo"
required-features = ["a"]
"#)
- .file("src/main.rs", "fn main() {}");
- p.build();
+ .file("src/main.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("install").arg("--features").arg("a"),
execs().with_status(0));
required-features = ["a"]
"#)
.file("src/foo_1.rs", "fn main() {}")
- .file("src/foo_2.rs", "fn main() {}");
- p.build();
+ .file("src/foo_2.rs", "fn main() {}")
+ .build();
assert_that(p.cargo("install"),
execs().with_status(0));
[features]
a = []
"#)
- .file("bar/src/lib.rs", "");
- p.build();
+ .file("bar/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
[features]
a = []
"#)
- .file("bar/src/lib.rs", "");
- p.build();
+ .file("bar/src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
"#)
.file("src/bin/foo.rs", "extern crate bar; fn main() {}")
.file("tests/foo.rs", "")
- .file("benches/foo.rs", "");
- p.build();
+ .file("benches/foo.rs", "")
+ .build();
assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
required-features = ["a"]
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "extern crate foo; fn main() {}");
- p.build();
+ .file("src/main.rs", "extern crate foo; fn main() {}")
+ .build();
assert_that(p.cargo("run"),
execs().with_status(101).with_stderr("\
"#)
.file("src/lib.rs", "")
.file("src/foo1.rs", "extern crate foo; fn main() {}")
- .file("src/foo2.rs", "extern crate foo; fn main() {}");
- p.build();
+ .file("src/foo2.rs", "extern crate foo; fn main() {}")
+ .build();
assert_that(p.cargo("run"),
execs().with_status(101).with_stderr("\
error: `cargo run` requires that a project only have one executable; \
use the `--bin` option to specify which one to run"));
-}
\ No newline at end of file
+}
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("src/main.rs", r#"
fn main() { println!("hello world"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bins"),
+ assert_that(p.cargo("run").arg("--bins"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("-q"),
+ assert_that(p.cargo("run").arg("-q"),
execs().with_status(0).with_stdout("\
hello
")
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("-q").arg("-v"),
+ assert_that(p.cargo("run").arg("-q").arg("-v"),
execs().with_status(101).with_stderr("\
[ERROR] cannot set both --verbose and --quiet
"));
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("-q"),
+ assert_that(p.cargo("run").arg("-q"),
execs().with_status(0));
}
assert_eq!(std::env::args().nth(1).unwrap(), "hello");
assert_eq!(std::env::args().nth(2).unwrap(), "world");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("hello").arg("world"),
+ assert_that(p.cargo("run").arg("hello").arg("world"),
execs().with_status(0));
}
"#)
.file("src/main.rs", r#"
fn main() { std::process::exit(2); }
- "#);
+ "#)
+ .build();
let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
[ERROR] process didn't exit successfully: `target[..]foo[..]` (exit code: 2)
");
}
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(2).with_stderr(output));
}
"#)
.file("src/main.rs", r#"
fn main() { std::process::exit(2); }
- "#);
+ "#)
+ .build();
let mut output = String::from("\
[COMPILING] foo v0.0.1 (file[..])
");
}
- assert_that(p.cargo_process("run").arg("-v"),
+ assert_that(p.cargo("run").arg("-v"),
execs().with_status(2).with_stderr(output));
}
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(101)
.with_stderr("[ERROR] a bin target must be available \
for `cargo run`\n"));
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("run").arg("--bins"),
+ assert_that(p.cargo("run").arg("--bins"),
execs().with_status(101)
.with_stderr("[ERROR] a bin target must be available \
for `cargo run`\n"));
"#)
.file("src/lib.rs", "")
.file("src/bin/a.rs", "")
- .file("src/bin/b.rs", "");
+ .file("src/bin/b.rs", "")
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(101)
.with_stderr("[ERROR] `cargo run` requires that a project only \
have one executable; use the `--bin` option \
"#)
.file("src/lib.rs", "")
.file("src/bin/a.rs", "")
- .file("src/bin/b.rs", "");
+ .file("src/bin/b.rs", "")
+ .build();
- assert_that(p.cargo_process("run").arg("--bins"),
+ assert_that(p.cargo("run").arg("--bins"),
execs().with_status(101)
.with_stderr("[ERROR] `cargo run` requires that a project only \
have one executable; use the `--bin` option \
#[allow(unused_extern_crates)]
extern crate foo;
fn main() { println!("hello b.rs"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bin").arg("a").arg("-v"),
+ assert_that(p.cargo("run").arg("--bin").arg("a").arg("-v"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("src/bin/a.rs", r#"
fn main() { println!("bin"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--example").arg("a"),
+ assert_that(p.cargo("run").arg("--example").arg("a"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("src/bin/a.rs", r#"
fn main() { println!("bin"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bins"),
+ assert_that(p.cargo("run").arg("--bins"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("src/bin/a.rs", r#"
fn main() { println!("bin"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--examples"),
+ assert_that(p.cargo("run").arg("--examples"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("examples/a.rs", r#"
fn main() { println!("example"); }
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("run").arg("--bin").arg("bin.rs"),
execs().with_status(101).with_stderr("\
"#)
.file("examples/b.rs", r#"
fn main() { println!("hello b.rs"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--bin").arg("a").arg("--example").arg("b"),
+ assert_that(p.cargo("run").arg("--bin").arg("a").arg("--example").arg("b"),
execs().with_status(101)
.with_stderr("[ERROR] `cargo run` can run at most one \
executable, but multiple were \
"#)
.file("examples/b.rs", r#"
fn main() { println!("hello b.rs"); }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run"),
+ assert_that(p.cargo("run"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
println!("fast2")
}
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("-v").arg("--release").arg("--example").arg("a"),
+ assert_that(p.cargo("run").arg("-v").arg("--release").arg("--example").arg("a"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({url}/bar)
name = "bar"
crate-type = ["dylib"]
"#)
- .file("bar/src/lib.rs", "pub fn bar() {}");
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
- assert_that(p.cargo_process("run").arg("hello").arg("world"),
+ assert_that(p.cargo("run").arg("hello").arg("world"),
execs().with_status(0));
}
"#)
.file("src/main.rs", r#"
fn main() { if cfg!(debug_assertions) { panic!() } }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--release"),
+ assert_that(p.cargo("run").arg("--release"),
execs().with_status(0).with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
[FINISHED] release [optimized] target(s) in [..]
"#)
.file("src/bar.rs", r#"
fn main() { }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run"), execs().with_status(0));
+ assert_that(p.cargo("run"), execs().with_status(0));
}
#[test]
assert_eq!(s[2], "--");
assert_eq!(s[3], "b");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("--").arg("a").arg("--").arg("b"),
+ assert_that(p.cargo("run").arg("--").arg("a").arg("--").arg("b"),
execs().with_status(0));
}
"#)
.file("src/main.rs", r#"
fn main() { println!("hello"); }
- "#);
+ "#)
+ .build();
let cwd = p.root().join("target").join("debug");
- p.cargo_process("build").exec_with_output().unwrap();
+ p.cargo("build").exec_with_output().unwrap();
assert_that(p.cargo("run").cwd(cwd),
execs().with_status(0)
#[test]
fn run_with_library_paths() {
- let mut p = project("foo");
+ let p = project("foo");
// Only link search directories within the target output directory are
// propagated through to dylib_path_envvar() (see #3366).
let mut dir2 = p.target_debug_dir();
dir2.push("dir=containing=equal=signs");
- p = p.file("Cargo.toml", r#"
+ let p = p
+ .file("Cargo.toml", r#"
[project]
name = "foo"
version = "0.0.1"
assert!(paths.contains(&r#"{}"#.into()));
assert!(paths.contains(&r#"{}"#.into()));
}}
- "##, dylib_path_envvar(), dir1.display(), dir2.display()));
+ "##, dylib_path_envvar(), dir1.display(), dir2.display()))
+ .build();
- assert_that(p.cargo_process("run"), execs().with_status(0));
+ assert_that(p.cargo("run"), execs().with_status(0));
}
#[test]
fn main() {
std::process::exit(1);
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("run").arg("-q"),
+ assert_that(p.cargo("run").arg("-q"),
execs().with_status(1)
.with_stdout("")
.with_stderr(""));
version = "0.0.1"
authors = []
"#)
- .file("d3/src/main.rs", "fn main() { println!(\"d2\"); }");
-
- let p = p.build();
+ .file("d3/src/main.rs", "fn main() { println!(\"d2\"); }")
+ .build();
let cargo = || {
let mut process_builder = p.cargo("run");
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("--lib").arg("-v"),
+ assert_that(p.cargo("rustc").arg("--lib").arg("-v"),
execs()
.with_status(0)
.with_stderr(format!("\
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("--lib").arg("-v")
+ assert_that(p.cargo("rustc").arg("--lib").arg("-v")
.arg("--").arg("-C").arg("debug-assertions=off"),
execs()
.with_status(0)
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("-v").arg("--bin").arg("foo")
+ assert_that(p.cargo("rustc").arg("-v").arg("--bin").arg("foo")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(0)
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("-v")
+ assert_that(p.cargo("rustc").arg("-v")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(101)
.file("src/bin/baz.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("-v").arg("--bin").arg("bar")
+ assert_that(p.cargo("rustc").arg("-v").arg("--bin").arg("bar")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(0)
.file("src/bin/baz.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("-v")
+ assert_that(p.cargo("rustc").arg("-v")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(101)
.file("tests/foo.rs", r#" "#)
.file("tests/bar.rs", r#" "#)
.file("tests/baz.rs", r#" "#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustc").arg("-v").arg("--test").arg("bar")
+ assert_that(p.cargo("rustc").arg("-v").arg("--test").arg("bar")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(0)
fn main() {
bar::baz()
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustc").arg("-v").arg("--").arg("-C").arg("debug-assertions"),
+ assert_that(foo.cargo("rustc").arg("-v").arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(0)
.with_stderr(format!("\
fn main() {
bar::baz()
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustc").arg("-v").arg("-p").arg("bar")
+ assert_that(foo.cargo("rustc").arg("-v").arg("-p").arg("bar")
.arg("--").arg("-C").arg("debug-assertions"),
execs()
.with_status(0)
"#)
.file("src/main.rs", r#"
fn main() {}
- "#);
- foo.build();
+ "#)
+ .build();
- let bar = project("bar")
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn main() {
if cfg!(flag = "1") { println!("Yeah from bar!"); }
}
- "#);
- bar.build();
+ "#)
+ .build();
- let baz = project("baz")
+ let _baz = project("baz")
.file("Cargo.toml", r#"
[package]
name = "baz"
fn main() {
if cfg!(flag = "1") { println!("Yeah from baz!"); }
}
- "#);
- baz.build();
+ "#)
+ .build();
assert_that(foo.cargo("rustc").arg("-v").arg("-p").arg("bar")
.arg("-p").arg("baz"),
#[test]
fn rustc_with_other_profile() {
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
authors = []
"#)
- .file("a/src/lib.rs", "");
- foo.build();
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(foo.cargo("rustc").arg("--profile").arg("test"),
+ assert_that(p.cargo("rustc").arg("--profile").arg("test"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustdoc").arg("-v"),
+ assert_that(p.cargo("rustdoc").arg("-v"),
execs()
.with_status(0)
.with_stderr(format!("\
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
+ assert_that(p.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
.with_stderr(format!("\
.file("src/lib.rs", r#"
extern crate bar;
pub fn foo() {}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
+ assert_that(foo.cargo("rustdoc").arg("-v").arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
.with_stderr(format!("\
fn main() {
bar::baz()
}
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
"#)
.file("src/lib.rs", r#"
pub fn baz() {}
- "#);
- bar.build();
+ "#)
+ .build();
- assert_that(foo.cargo_process("rustdoc").arg("-v").arg("-p").arg("bar")
+ assert_that(foo.cargo("rustdoc").arg("-v").arg("-p").arg("bar")
.arg("--").arg("--cfg=foo"),
execs()
.with_status(0)
.file("src/main.rs", r#"
fn main() {}
"#)
- .file("src/lib.rs", r#" "#);
+ .file("src/lib.rs", r#" "#)
+ .build();
- assert_that(p.cargo_process("rustdoc").arg("-v")
+ assert_that(p.cargo("rustdoc").arg("-v")
.arg("--").arg("--cfg=foo"),
execs()
.with_status(101)
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo").arg("-v"),
execs().with_status(0)
.file(".cargo/config", r#"
[build]
rustdocflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("doc").arg("-v"),
execs().with_status(0)
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--bogus"),
execs().with_status(101));
version = "0.0.1"
authors = []
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("doc").env("RUSTDOCFLAGS", "--cfg=foo"),
execs().with_status(0));
.file("benches/d.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run1(_ben: &mut test::Bencher) { }"#);
- p.build();
+ #[bench] fn run1(_ben: &mut test::Bencher) { }"#)
+ .build();
// Use RUSTFLAGS to pass an argument that will generate an error
assert_that(p.cargo("build").env("RUSTFLAGS", "-Z bogus")
fn main() { }
#[cfg(not(foo))]
fn main() { }
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
.file("src/lib.rs", "")
.file("build.rs", r#"
fn main() { }
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
fn main() { }
#[cfg(not(foo))]
fn main() { }
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
"#)
.file("src/lib.rs", r#"
fn foo() { }
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
.file("benches/d.rs", r#"
#![feature(test)]
extern crate test;
- #[bench] fn run1(_ben: &mut test::Bencher) { }"#);
- p.build();
+ #[bench] fn run1(_ben: &mut test::Bencher) { }"#)
+ .build();
let host = &rustc_host();
fn main() { }
#[cfg(foo)]
fn main() { }
- "#);
- p.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo")
.file("src/lib.rs", "")
.file("build.rs", r#"
fn main() { }
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(foo)]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo")
fn main() { }
#[cfg(foo)]
fn main() { }
- "#);
- p.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo")
"#)
.file("src/lib.rs", r#"
fn foo() { }
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(foo)]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(foo.cargo("build").env("RUSTFLAGS", "--cfg foo")
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["-Z", "bogus"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build")
.arg("--lib"),
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("build"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(not(foo))]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
assert_that(foo.cargo("build"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["-Z", "bogus"]
- "#);
- p.build();
+ "#)
+ .build();
let ref host = rustc_host();
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(p.cargo("build")
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(foo)]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(foo.cargo("build")
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(p.cargo("build")
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- let bar = project("bar")
+ "#)
+ .build();
+ let _bar = project("bar")
.file("Cargo.toml", r#"
[package]
name = "bar"
fn bar() { }
#[cfg(foo)]
fn bar() { }
- "#);
- foo.build();
- bar.build();
+ "#)
+ .build();
let host = rustc_host();
assert_that(foo.cargo("build")
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build"),
execs().with_status(0));
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p.build();
+ "#)
+ .build();
assert_that(p.cargo("build").env("RUSTFLAGS", "--cfg foo"),
execs().with_status(0));
name = "foo"
version = "0.0.1"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
.file(".cargo/config", &format!("
[target.{}]
rustflags = [\"-Z\", \"bogus\"]
- ", rustc_host()));
- p.build();
+ ", rustc_host()))
+ .build();
assert_that(p.cargo("build")
.arg("--lib"),
[target.{}]
rustflags = [\"-Z\", \"bogus\"]
- ", rustc_host()));
- p.build();
+ ", rustc_host()))
+ .build();
assert_that(p.cargo("build")
.arg("--lib"),
.file(".cargo/config", &format!(r#"
[target.'cfg({})']
rustflags = ["--cfg", "bar"]
- "#, if rustc_host().contains("-windows-") {"windows"} else {"not(windows)"}));
- p.build();
-
+ "#, if rustc_host().contains("-windows-") {"windows"} else {"not(windows)"}))
+ .build();
+
assert_that(p.cargo("build").arg("--lib").arg("-v"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.1 ([..])
[target.'cfg({})']
rustflags = ["--cfg", "bar"]
- "#, if rustc_host().contains("-windows-") { "windows" } else { "not(windows)" }));
- p.build();
+ "#, if rustc_host().contains("-windows-") { "windows" } else { "not(windows)" }))
+ .build();
assert_that(p.cargo("build").arg("--lib").arg("-v"),
execs().with_status(0).with_stderr("\
.file(".cargo/config", r#"
[build]
rustflags = ["--cfg", "foo"]
- "#);
- p1.build();
+ "#)
+ .build();
assert_that(p1.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
.file(".cargo/config", r#"
[build]
rustflags = "--cfg foo"
- "#);
- p2.build();
+ "#)
+ .build();
assert_that(p2.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[target.{}]
rustflags = ["--cfg", "foo"]
"#, rustc_host()))
- .file("src/lib.rs", "");
- p1.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p1.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
[target.{}]
rustflags = "--cfg foo"
"#, rustc_host()))
- .file("src/lib.rs", "");
- p2.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p2.cargo("build").arg("-v"),
execs().with_status(0).with_stderr("\
fs::create_dir_all(config.parent().unwrap()).unwrap();
fs::create_dir_all(&api_path().join("api/v1")).unwrap();
- repo(®istry_path())
+ let _ = repo(®istry_path())
.file("config.json", &format!(r#"{{
"dl": "{0}",
"api": "{0}"
[dependencies]
bar = "*"
"#)
- .file("src/lib.rs", "");
+ .file("src/lib.rs", "")
+ .build();
Package::new("bar", "0.1.0").publish();
- assert_that(foo.cargo_process("build"),
+ assert_that(foo.cargo("build"),
execs().with_status(0));
let index = find_index();
#[test]
fn test_hello() {
assert_eq!(hello(), "hello")
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "pub fn bar() {}");
+ .file("bar/src/lib.rs", "pub fn bar() {}")
+ .build();
- assert_that(p.cargo_process("test").arg("-v").arg("--release"),
+ assert_that(p.cargo("test").arg("-v").arg("--release"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
[RUNNING] [..] -C opt-level=3 [..]
[1, i32::max_value()].iter().sum::<i32>();
});
assert!(r.is_err());
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build").arg("--release"),
+ assert_that(p.cargo("build").arg("--release"),
execs().with_status(0));
assert_that(&p.release_bin("foo"), existing_file());
.file("src/main.rs", r#"
fn main() {}
#[test] fn test_hello() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v").arg("hello"),
+ assert_that(p.cargo("test").arg("-v").arg("hello"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.5.0 ({url})
[RUNNING] `rustc [..] src[/]main.rs [..]`
.file("tests/foo.rs", r#"
extern crate foo;
#[test] fn test_test() { foo::foo() }
- "#);
+ "#)
+ .build();
- let output = p.cargo_process("test").arg("-v").exec_with_output().unwrap();
+ let output = p.cargo("test").arg("-v").exec_with_output().unwrap();
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("test bin_test"), "bin_test missing\n{}", output);
assert!(output.contains("test lib_test"), "lib_test missing\n{}", output);
#[test]
fn test_hello() {
assert_eq!(hello(), "nope")
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
#[test]
fn test_hello() {
assert!(false)
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
assert_that(process(&p.bin("foo")),
#[test]
fn test_hello() {
assert!(false)
- }"#);
+ }"#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_stderr(format!("\
[COMPILING] foo v0.5.0 ({url})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
#[test]
fn bin_test() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
fn bar_test() {
foo::foo();
}
- ");
- let p2 = project("foo")
+ ")
+ .build();
+ let _p2 = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
#[test]
fn foo_test() {}
- ");
+ ")
+ .build();
- p2.build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ([..])
#[test]
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
.file("tests/test.rs", r#"
#[test]
fn foo() { }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0))
}
#[test]
fn external_test() { assert_eq!(foo::get_hello(), "Hello") }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"#)
.file("examples/dont-run-me-i-will-fail.rs", r#"
fn main() { panic!("Examples should not be run by 'cargo test'"); }
- "#);
- assert_that(p.cargo_process("test"),
+ "#)
+ .build();
+ assert_that(p.cargo("test"),
execs().with_status(0));
}
.file("src/lib.rs", "
#[test] fn foo() {}
#[test] fn bar() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test").arg("bar"),
+ assert_that(p.cargo("test").arg("bar"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
#[test]
fn dummy_test() { }
- "#);
+ "#)
+ .build();
- p.cargo_process("build");
+ p.cargo("build");
for _ in 0..2 {
assert_that(p.cargo("test"),
#[test]
fn bin_test() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr(format!("\
[COMPILING] foo v0.0.1 ({})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
#[test]
fn test() { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
#[test]
fn test() { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
#[test]
fn test() { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] syntax v0.0.1 ({dir})
#[test]
fn test() { syntax::foo() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[bench]
fn external_bench(_b: &mut test::Bencher) {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]`
#[test]
fn external_test() { assert_eq!(syntax::get_hello(), "Hello") }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]`
fn main() {
println!("example1");
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(101)
.with_stderr("\
[ERROR] failed to parse manifest at `[..]`
let status = Command::new("target/debug/foo").status().unwrap();
assert_eq!(status.code(), Some(101));
}
- "#);
+ "#)
+ .build();
- let output = p.cargo_process("test").arg("-v").exec_with_output().unwrap();
+ let output = p.cargo("test").arg("-v").exec_with_output().unwrap();
let output = str::from_utf8(&output.stdout).unwrap();
assert!(output.contains("main_test ... ok"), "no main_test\n{}", output);
assert!(output.contains("test_test ... ok"), "no test_test\n{}", output);
"#)
.file("bar/src/lib.rs", "
pub fn baz() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] bar v0.0.1 ({dir}/bar)
.file("src/lib.rs", "
#[test]
fn foo() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("src/lib.rs", "
#[test]
fn foo() {}
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("src/lib.rs", "
#[test]
fn foo() { panic!() }
- ");
+ ")
+ .build();
- assert_that(p.cargo_process("test").arg("--no-run"),
+ assert_that(p.cargo("test").arg("--no-run"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
path="src/bin2.rs"
"#)
.file("src/bin1.rs", "#[test] fn test1() { }")
- .file("src/bin2.rs", "#[test] fn test2() { }");
+ .file("src/bin2.rs", "#[test] fn test2() { }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--bin").arg("bin2"),
+ assert_that(prj.cargo("test").arg("--bin").arg("bin2"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("tests/mytest.rs", "#[test] fn test_in_test() { }")
.file("benches/mybench.rs", "#[test] fn test_in_bench() { }")
.file("examples/myexm.rs", "#[test] fn test_in_exm() { }
- fn main() { panic!(\"Don't execute me!\"); }");
+ fn main() { panic!(\"Don't execute me!\"); }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--bins"),
+ assert_that(prj.cargo("test").arg("--bins"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("src/bin/a.rs", "fn main() { }")
.file("src/bin/b.rs", "#[test] fn test_b() { } fn main() { }")
.file("tests/a.rs", "#[test] fn test_a() { }")
- .file("tests/b.rs", "#[test] fn test_b() { }");
+ .file("tests/b.rs", "#[test] fn test_b() { }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--test").arg("b"),
+ assert_that(prj.cargo("test").arg("--test").arg("b"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("tests/mytest.rs", "#[test] fn test_in_test() { }")
.file("benches/mybench.rs", "#[test] fn test_in_bench() { }")
.file("examples/myexm.rs", "#[test] fn test_in_exm() { }
- fn main() { panic!(\"Don't execute me!\"); }");
+ fn main() { panic!(\"Don't execute me!\"); }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--tests"),
+ assert_that(prj.cargo("test").arg("--tests"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("tests/mytest.rs", "#[test] fn test_in_test() { }")
.file("benches/mybench.rs", "#[test] fn test_in_bench() { }")
.file("examples/myexm.rs", "#[test] fn test_in_exm() { }
- fn main() { panic!(\"Don't execute me!\"); }");
+ fn main() { panic!(\"Don't execute me!\"); }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--benches"),
+ assert_that(prj.cargo("test").arg("--benches"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
.file("tests/mytest.rs", "#[test] fn test_in_test() { }")
.file("benches/mybench.rs", "#[test] fn test_in_bench() { }")
.file("examples/myexm.rs", "#[test] fn test_in_exm() { }
- fn main() { panic!(\"Don't execute me!\"); }");
+ fn main() { panic!(\"Don't execute me!\"); }")
+ .build();
- assert_that(prj.cargo_process("test").arg("--examples"),
+ assert_that(prj.cargo("test").arg("--examples"),
execs().with_status(0)
.with_stderr(format!("\
[COMPILING] foo v0.0.1 ({dir})
harness = false
"#)
.file("src/main.rs", "fn main() {}")
- .file("foo.rs", "fn main() {}");
+ .file("foo.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("test").arg("--").arg("--nocapture"),
+ assert_that(p.cargo("test").arg("--").arg("--nocapture"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
"#)
.file("d2/src/lib.rs", "")
.file("d2/src/main.rs", "#[allow(unused_extern_crates)] extern crate d2; fn main() {}");
- p.build();
+ let p = p.build();
println!("d1");
assert_that(p.cargo("test").arg("-p").arg("d1"),
version = "0.0.1"
authors = []
"#)
- .file("c/src/lib.rs", "");
+ .file("c/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
assert_that(p.cargo("test"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("build"), execs().with_status(0));
+ assert_that(p.cargo("build"), execs().with_status(0));
p.root().move_into_the_past();
assert_that(p.cargo("test").arg("-p").arg("b"),
execs().with_status(0));
pub fn bar() {
f8!();
}
- "#);
- assert_that(p.cargo_process("test"),
+ "#)
+ .build();
+ assert_that(p.cargo("test"),
execs().with_status(0));
assert_that(p.cargo("run")
.arg("--example").arg("e1").arg("--release").arg("-v"),
path = "d1.rs"
"#)
.file("d1/d1.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("-p").arg("d1"),
execs().with_status(0)
authors = []
"#)
.file("src/bin/foo.rs", r#"fn main() { println!("bin"); }"#)
- .file("examples/foo.rs", r#"fn main() { println!("example"); }"#);
+ .file("examples/foo.rs", r#"fn main() { println!("example"); }"#)
+ .build();
- assert_that(p.cargo_process("test").arg("--no-run").arg("-v"),
+ assert_that(p.cargo("test").arg("--no-run").arg("-v"),
execs().with_status(0)
.with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({dir})
authors = []
"#)
.file("src/bin/foo.rs", r#"fn main() { println!("bin"); }"#)
- .file("examples/foo.rs", r#"fn main() { println!("example"); }"#);
+ .file("examples/foo.rs", r#"fn main() { println!("example"); }"#)
+ .build();
println!("first");
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("examples/foo"), existing_file());
println!("second");
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0)
.with_stderr("\
[..]
authors = []
"#)
.file("src/lib.rs", "")
- .file("src/main.rs", "fn main() {}");
+ .file("src/main.rs", "fn main() {}")
+ .build();
- assert_that(p.cargo_process("build").arg("-v"),
+ assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
authors = []
"#)
.file("src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("run").arg("--example").arg("foo"),
execs().with_status(101).with_stderr("\
/// ```
#[cfg(feature = "bar")]
pub fn foo() -> i32 { 1 }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("--features").arg("bar"),
+ assert_that(p.cargo("test").arg("--features").arg("bar"),
execs().with_status(0)
.with_stderr("\
[COMPILING] foo [..]
/// assert_eq!(foo_bar::foo(), 1);
/// ```
pub fn foo() -> i32 { 1 }
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
version = "0.0.1"
authors = []
"#)
- .file("b/src/lib.rs", "");
+ .file("b/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-v"),
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
/// ```
pub fn foo() {}
"#)
- .file("tests/foo.rs", "");
+ .file("tests/foo.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("--test=foo"),
+ assert_that(p.cargo("test").arg("--test=foo"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
/// foo::foo();
/// ```
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.1 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
/// foo::foo();
/// ```
pub fn foo() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stdout(""));
}
.file("bar/src/lib.rs", r#"
#[allow(unused_extern_crates)]
extern crate foo;
- "#);
- assert_that(p.cargo_process("test"),
+ "#)
+ .build();
+ assert_that(p.cargo("test"),
execs().with_status(0).with_stderr("\
[COMPILING] foo v0.0.1 ([..])
[COMPILING] bar v0.0.1 ([..])
build = "build.rs"
"#)
.file("bar/src/lib.rs", "")
- .file("bar/build.rs", "fn main() {}");
- assert_that(p.cargo_process("test"),
+ .file("bar/build.rs", "fn main() {}")
+ .build();
+ assert_that(p.cargo("test"),
execs().with_status(0));
}
fn sub_one_test() {
assert_eq!(sub_one(1), 0);
}
- "#);
- assert_that(p.cargo_process("test").arg("--no-fail-fast"),
+ "#)
+ .build();
+ assert_that(p.cargo("test").arg("--no-fail-fast"),
execs().with_status(101)
.with_stderr_contains("\
[COMPILING] foo v0.0.1 ([..])
doctest = false
"#)
.file("d2/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("-p").arg("d1").arg("-p").arg("d2"),
execs().with_status(0)
.file("src/lib.rs", "")
.file("src/main.rs", "fn main() {}")
.file("tests/foo.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
authors = []
"#)
.file("a/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("-v").arg("--no-run").arg("--release")
.arg("-p").arg("foo").arg("-p").arg("a"),
authors = []
"#)
.file("a/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("-v").arg("--no-run")
.arg("--features").arg("a").arg("-p").arg("a"),
}
"#)
.file("tests/foo.rs", "this is not rust");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").arg("--doc"),
execs().with_status(0)
version = "0.0.1"
authors = []
"#)
- .file("bar/src/lib.rs", "");
- assert_that(p.cargo_process("test").arg("-v"),
+ .file("bar/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0));
}
fn main() {
println!("hello!");
}
- "#);
- assert_that(p.cargo_process("test").arg("-v"),
+ "#)
+ .build();
+ assert_that(p.cargo("test").arg("-v"),
execs().with_status(0)
.with_stdout("hello!\n")
.with_stderr("\
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
- assert_that(p.cargo_process("test")
+ .file("a/src/lib.rs", "")
+ .build();
+ assert_that(p.cargo("test")
.arg("--release").arg("-v")
.arg("-p").arg("foo")
.arg("-p").arg("a"),
authors = []
"#)
.file("libs/mock_serde_codegen/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("test")
.arg("--package").arg("feature_a")
authors = []
"#)
.file("a/src/lib.rs", "");
- p.build();
+ let p = p.build();
println!("test");
assert_that(p.cargo("test").arg("-v"), execs().with_status(0));
println!("bench");
version = "0.0.1"
authors = []
"#)
- .file("a/src/lib.rs", "");
+ .file("a/src/lib.rs", "")
+ .build();
- assert_that(p.cargo_process("test").arg("-v")
+ assert_that(p.cargo("test").arg("-v")
.arg("-p").arg("a")
.arg("-p").arg("foo")
.arg("--features").arg("foo"),
.file("bar/src/lib.rs", r#"
#[test]
fn bar_test() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test")
+ assert_that(p.cargo("test")
.arg("--all"),
execs().with_status(0)
.with_stdout_contains("test foo_test ... ok")
pub fn baz() {
assert!(false);
}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test")
+ assert_that(p.cargo("test")
.arg("--all")
.arg("--exclude")
.arg("baz"),
.file("b/src/lib.rs", r#"
#[test]
fn b() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test")
+ assert_that(p.cargo("test")
.arg("--all"),
execs().with_status(0)
.with_stdout_contains("test a ... ok")
.file("b/src/lib.rs", r#"
#[test]
fn b() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test"),
+ assert_that(p.cargo("test"),
execs().with_status(0)
.with_stdout_contains("test a ... ok")
.with_stdout_contains("test b ... ok"));
.file("a/src/lib.rs", r#"
#[test]
fn a() {}
- "#);
+ "#)
+ .build();
Package::new("a", "0.1.0").publish();
- assert_that(p.cargo_process("test")
+ assert_that(p.cargo("test")
.arg("--all"),
execs().with_status(0)
.with_stdout_contains("test a ... ok"));
"#)
.file("b/src/lib.rs", r#"
pub fn b() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("--doc").arg("-v"),
+ assert_that(p.cargo("test").arg("--doc").arg("-v"),
execs().with_status(0));
}
"#)
.file("tests/c.rs", r#"
does not compile
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("--verbose")
+ assert_that(p.cargo("test").arg("--verbose")
.arg("--bin").arg("a").arg("--bin").arg("b")
.arg("--example").arg("a").arg("--example").arg("b")
.arg("--test").arg("a").arg("--test").arg("b"),
[dependencies]
b = "0.1"
"#)
- .file("c/src/lib.rs", "");
+ .file("c/src/lib.rs", "")
+ .build();
Package::new("b", "0.1.0").publish();
- assert_that(p.cargo_process("test").arg("--all").arg("-v"),
+ assert_that(p.cargo("test").arg("--all").arg("-v"),
execs().with_status(0));
}
let p = project("env_test")
.file("Cargo.toml", &basic_lib_manifest("env_test"))
- .file("src/lib.rs", &src);
+ .file("src/lib.rs", &src)
+ .build();
- let mut pr = p.cargo_process("test");
+ let mut pr = p.cargo("test");
let cargo = cargo_exe().canonicalize().unwrap();
assert_that(pr.args(&["--lib", "--", "--nocapture"]),
execs().with_status(0)
"#)
.file("tests/z.rs", r#"
#[test] fn test_z() {}
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("--all"),
+ assert_that(p.cargo("test").arg("--all"),
execs().with_status(0)
.with_stdout_contains("
running 1 test
"#)
.file("tests/foo.rs", r#"
extern crate foo;
- "#);
+ "#)
+ .build();
- assert_that(p.cargo_process("test").arg("--all"),
+ assert_that(p.cargo("test").arg("--all"),
execs().with_status(0));
}
[dependencies]
testless = "0.1.0"
"#)
- .file("src/lib.rs", "");
- p.build();
+ .file("src/lib.rs", "")
+ .build();
assert_that(p.cargo("test"), execs().with_status(0));
assert_that(p.cargo("test").arg("--package").arg("testless"),
pub fn noop(_input: TokenStream) -> TokenStream {
"".parse().unwrap()
}
- "#);
+ "#)
+ .build();
Package::new("foo", "0.1.0").publish();
Package::new("bar", "0.1.0")
.dep("foo", "0.1")
.file("src/lib.rs", "extern crate foo;")
.publish();
- workspace.build();
assert_that(workspace.cargo("test").arg("--all").arg("--target").arg(rustc_host()),
execs().with_status(0));
}
fn this_fails() {
panic!();
}
- "#);
- assert_that(p.cargo_process("test")
+ "#)
+ .build();
+ assert_that(p.cargo("test")
.arg("--no-fail-fast"),
execs()
.with_status(101)
[target.{}]
ar = "nonexistent-ar"
linker = "nonexistent-linker"
- "#, target));
+ "#, target))
+ .build();
- assert_that(foo.cargo_process("build").arg("--verbose"),
+ assert_that(foo.cargo("build").arg("--verbose"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]`
[target.{target}]
ar = "{ar}"
linker = "{linker}"
- "#, target = target, ar = config.0, linker = config.1));
+ "#, target = target, ar = config.0, linker = config.1))
+ .build();
let output = if cfg!(windows) {
(r#"C:\bogus\nonexistent-ar"#, r#"C:\bogus\nonexistent-linker"#)
(r#"/bogus/nonexistent-ar"#, r#"/bogus/nonexistent-linker"#)
};
- assert_that(foo.cargo_process("build").arg("--verbose"),
+ assert_that(foo.cargo("build").arg("--verbose"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
[target.{target}]
ar = "{ar}"
linker = "{linker}"
- "#, target = target, ar = config.0, linker = config.1));
+ "#, target = target, ar = config.0, linker = config.1))
+ .build();
let foo_path = origin.root().join("foo");
let foo_url = path2url(foo_path.clone());
format!(r#"{}/./tools/nonexistent-linker"#, prefix))
};
- assert_that(origin.cargo_process("build").cwd(foo_path).arg("--verbose"),
+ assert_that(origin.cargo("build").cwd(foo_path).arg("--verbose"),
execs().with_stderr(&format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..] -C ar={ar} -C linker={linker} [..]`
fn custom_runner() {
let target = rustc_host();
- let foo = project("foo")
+ let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
.file(".cargo/config", &format!(r#"
[target.{}]
runner = "nonexistent-runner -r"
- "#, target));
-
- foo.build();
+ "#, target))
+ .build();
- assert_that(foo.cargo("run").args(&["--", "--param"]),
+ assert_that(p.cargo("run").args(&["--", "--param"]),
execs().with_stderr_contains(&format!("\
[COMPILING] foo v0.0.1 ({url})
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target[/]debug[/]foo[EXE] --param`
-", url = foo.url())));
+", url = p.url())));
- assert_that(foo.cargo("test").args(&["--test", "test", "--verbose", "--", "--param"]),
+ assert_that(p.cargo("test").args(&["--test", "test", "--verbose", "--", "--param"]),
execs().with_stderr_contains(&format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r [..][/]target[/]debug[/]deps[/]test-[..][EXE] --param`
-", url = foo.url())));
+", url = p.url())));
- assert_that(foo.cargo("bench").args(&["--bench", "bench", "--verbose", "--", "--param"]),
+ assert_that(p.cargo("bench").args(&["--bench", "bench", "--verbose", "--", "--param"]),
execs().with_stderr_contains(&format!("\
[COMPILING] foo v0.0.1 ({url})
[RUNNING] `rustc [..]`
[RUNNING] `rustc [..]`
[FINISHED] release [optimized] target(s) in [..]
[RUNNING] `nonexistent-runner -r [..][/]target[/]release[/]deps[/]bench-[..][EXE] --param --bench`
-", url = foo.url())));
+", url = p.url())));
}
fn cargo_verify_project_path_to_cargo_toml_relative() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg("foo/Cargo.toml")
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_verify_project_path_to_cargo_toml_absolute() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.arg("--manifest-path").arg(p.root().join("Cargo.toml"))
.cwd(p.root().parent().unwrap()),
execs().with_status(0)
fn cargo_verify_project_cwd() {
let p = project("foo")
.file("Cargo.toml", &basic_bin_manifest("foo"))
- .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
- assert_that(p.cargo_process("verify-project")
+ assert_that(p.cargo("verify-project")
.cwd(p.root()),
execs().with_status(0)
.with_stdout(verify_project_success_output()));
#[test]
fn simple() {
- let p = project("foo");
- p.build();
+ let p = project("foo").build();
assert_that(p.cargo("version"),
execs().with_status(0).with_stdout(&format!("{}\n",
#[test]
#[cfg_attr(target_os = "windows", ignore)]
fn version_works_without_rustc() {
- let p = project("foo");
- assert_that(p.cargo_process("version").env("PATH", ""),
+ let p = project("foo").build();
+ assert_that(p.cargo("version").env("PATH", ""),
execs().with_status(0));
}
#[test]
fn version_works_with_bad_config() {
let p = project("foo")
- .file(".cargo/config", "this is not toml");
- assert_that(p.cargo_process("version"),
+ .file(".cargo/config", "this is not toml")
+ .build();
+ assert_that(p.cargo("version"),
execs().with_status(0));
}
.file(".cargo/config", r#"
[build]
target-dir = 4
- "#);
- assert_that(p.cargo_process("version"),
+ "#)
+ .build();
+ assert_that(p.cargo("version"),
execs().with_status(0));
}
extern crate cargotest;
extern crate hamcrest;
-use cargotest::support::{project, execs, ProjectBuilder};
+use cargotest::support::{project, execs, Project};
use cargotest::support::registry::Package;
use hamcrest::assert_that;
.publish();
}
-fn make_upstream(main_src: &str) -> ProjectBuilder {
+fn make_upstream(main_src: &str) -> Project {
project("bar")
.file("Cargo.toml", r#"
[package]
foo = "*"
"#)
.file("src/main.rs", &format!("fn main() {{ {} }}", main_src))
+ .build()
}
#[test]
fn no_warning_on_success() {
make_lib("");
let upstream = make_upstream("");
- assert_that(upstream.cargo_process("build"),
+ assert_that(upstream.cargo("build"),
execs().with_status(0)
.with_stderr("\
[UPDATING] registry `[..]`
fn no_warning_on_bin_failure() {
make_lib("");
let upstream = make_upstream("hi()");
- assert_that(upstream.cargo_process("build"),
+ assert_that(upstream.cargo("build"),
execs().with_status(101)
.with_stdout_does_not_contain("hidden stdout")
.with_stderr_does_not_contain("hidden stderr")
fn warning_on_lib_failure() {
make_lib("err()");
let upstream = make_upstream("");
- assert_that(upstream.cargo_process("build"),
+ assert_that(upstream.cargo("build"),
execs().with_status(101)
.with_stdout_does_not_contain("hidden stdout")
.with_stderr_does_not_contain("hidden stderr")
workspace = ".."
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
"#)
.file("bar/src/main.rs", "fn main() {}")
.file("bar/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
"#)
.file("baz/src/main.rs", "fn main() {}")
.file("baz/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
"#)
.file("bar/src/main.rs", "fn main() {}")
.file("bar/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("foo")),
execs().with_status(0));
workspace = ".."
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("bar")),
execs().with_status(101)
workspace = "foo"
"#)
.file("src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
members = ["foo"]
"#)
.file("src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
[workspace]
"#)
.file("src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
}
members = [".."]
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
workspace = "../baz"
"#)
.file("baz/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
workspace = ".."
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101));
dep1 = "< 0.1.5"
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
Package::new("dep1", "0.1.3").publish();
Package::new("dep1", "0.1.8").publish();
dep1 = "*"
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
Package::new("dep1", "0.1.3").publish();
dep1 = "0.1"
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
Package::new("dep1", "0.1.0").publish();
Package::new("dep2", "0.1.0").publish();
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("bar")),
execs().with_status(0));
assert_that(&p.root().join("Cargo.lock"), existing_file());
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root()).args(&["--package", "bar"]),
execs().with_status(0));
assert_that(&p.root().join("Cargo.lock"), existing_file());
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("bar")),
execs().with_status(101)
.with_stderr("\
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
}
.file("Cargo.toml", r#"
[workspace]
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
.file("bar/Cargo.toml", r#"
[workspace]
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
.with_stderr("\
authors = []
"#)
.file("p3/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("p1")),
execs().with_status(0));
[workspace]
"#)
.file("src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("new").arg("--lib").arg("bar").env("USER", "foo"),
execs().with_status(0)
bar = "*"
"#)
.file("baz/src/lib.rs", "");
- p.build();
+ let p = p.build();
Package::new("foo", "1.0.0").publish();
Package::new("bar", "1.0.0").publish();
assert_eq!(lib::foo(), 0);
}
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("run").cwd(p.root().join("bin")),
execs().with_status(0));
.file("src/lib.rs", r#"
pub fn foo() -> u32 { 0 }
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
version = "0.1.0"
"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("a")), execs().with_status(0));
}
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("update"),
execs().with_status(101)
authors = ["mbrubeck@example.com"]
"#)
.file("baz/src/lib.rs", r#"pub fn do_stuff() {}"#);
- p.build();
+ let p = p.build();
assert_that(p.cargo("test").args(&["-p", "bar"]),
execs().with_status(0));
authors = []
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("bar")),
execs().with_status(101)
workspace = "../foo"
"#)
.file("bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("foo")), execs().with_status(0));
assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0));
authors = []
"#)
.file("subproj/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root())
.arg("--manifest-path").arg("./Cargo.toml"),
authors = []
"#)
.file("foo/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("ws")),
execs().with_status(0));
authors = []
"#)
.file("bar/src/lib.rs", "pub fn f() { }");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("ws")),
execs().with_status(0));
authors = []
"#)
.file("foo/bar/src/lib.rs", "pub fn f() { }");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build").cwd(p.root().join("ws")),
execs().with_status(0));
authors = []
"#)
.file("foo/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
authors = []
"#)
.file("foo/bar/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
authors = []
"#)
.file("foo/bar/src/lib.rs", "");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(0));
authors = []
"#)
.file("crates/qux/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"), execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
"#)
.file("src/main.rs", "fn main() {}")
.file("crates/bar/src/main.rs", "fn main() {}");
- p.build();
+ let p = p.build();
assert_that(p.cargo("build"),
execs().with_status(101)
"#)
.file("caller2/src/main.rs", "fn main() {}")
.file("caller2/src/lib.rs", "");
- p.build();
+ let p = p.build();
// Build the entire workspace
assert_that(p.cargo("build").arg("--all"),