2018-01-31 18:30:01 +00:00
|
|
|
|
use std::env;
|
|
|
|
|
use std::fs::{self, File};
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
use std::io::{Read, Write};
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
2016-07-28 17:26:32 +00:00
|
|
|
|
use cargotest::sleep_ms;
|
2018-05-01 03:39:07 +00:00
|
|
|
|
use cargotest::support::{basic_lib_manifest, execs, git, project};
|
2016-05-15 00:14:24 +00:00
|
|
|
|
use cargotest::support::registry::Package;
|
2018-03-14 15:17:44 +00:00
|
|
|
|
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn simple_explicit() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 15:25:12 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn simple_explicit_default_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:25:12 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
default-members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-11-23 15:25:12 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:25:12 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-11-23 15:25:12 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.bin("foo"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 00:14:24 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn inferred_root() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn inferred_path_dep() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "bar" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn transitive_path_dep() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "bar" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
baz = { path = "../baz" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("baz/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.bin("baz"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.bin("baz"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("baz")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.bin("baz"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("baz/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn parent_pointer_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "../bar" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
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),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.root().join("foo/Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn same_names_in_workspace() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: two packages named `foo` in this workspace:
|
|
|
|
|
- [..]Cargo.toml
|
|
|
|
|
- [..]Cargo.toml
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn parent_doesnt_point_to_child() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: current package believes it's in a workspace when it's not:
|
|
|
|
|
current: [..]Cargo.toml
|
|
|
|
|
workspace: [..]Cargo.toml
|
|
|
|
|
|
|
|
|
|
this may be fixable [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn invalid_parent_pointer() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: failed to read `[..]Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn invalid_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: failed to read `[..]Cargo.toml`
|
|
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn bare_workspace_ok() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn two_roots() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = [".."]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: multiple workspace roots found in the same workspace:
|
|
|
|
|
[..]
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn workspace_isnt_root() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("error: root of a workspace inferred but wasn't a root: [..]"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn dangling_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../baz"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../baz"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("baz/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: package `[..]` is a member of the wrong workspace
|
|
|
|
|
expected: [..]
|
|
|
|
|
actual: [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn cycle() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = ".."
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(101));
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn share_dependencies() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "0.1"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "< 0.1.5"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.3").publish();
|
|
|
|
|
Package::new("dep1", "0.1.8").publish();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[UPDATING] registry `[..]`
|
|
|
|
|
[DOWNLOADING] dep1 v0.1.3 ([..])
|
2016-02-03 18:54:07 +00:00
|
|
|
|
[COMPILING] dep1 v0.1.3
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[COMPILING] foo v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn fetch_fetches_all() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "*"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.3").publish();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("fetch"),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[UPDATING] registry `[..]`
|
|
|
|
|
[DOWNLOADING] dep1 v0.1.3 ([..])
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn lock_works_for_everyone() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
dep2 = "0.1"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
dep1 = "0.1"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.0").publish();
|
|
|
|
|
Package::new("dep2", "0.1.0").publish();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("generate-lockfile"),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(0)
|
|
|
|
|
.with_stderr("[UPDATING] registry `[..]`"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
Package::new("dep1", "0.1.1").publish();
|
|
|
|
|
Package::new("dep2", "0.1.1").publish();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[DOWNLOADING] dep2 v0.1.0 ([..])
|
2016-02-03 18:54:07 +00:00
|
|
|
|
[COMPILING] dep2 v0.1.0
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[COMPILING] foo v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[DOWNLOADING] dep1 v0.1.0 ([..])
|
2016-02-03 18:54:07 +00:00
|
|
|
|
[COMPILING] dep1 v0.1.0
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
2017-01-12 01:03:36 +00:00
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn virtual_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-12 12:57:19 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn explicit_package_argument_works_with_virtual_manifest() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-12-12 12:57:19 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-12-12 12:57:19 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-12-12 12:57:19 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root()).args(&["--package", "bar"]),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-12-12 12:57:19 +00:00
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 00:14:24 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn virtual_misconfigure() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: current package believes it's in a workspace when it's not:
|
|
|
|
|
current: [..]bar[..]Cargo.toml
|
|
|
|
|
workspace: [..]Cargo.toml
|
|
|
|
|
|
|
|
|
|
this may be fixable by adding `bar` to the `workspace.members` array of the \
|
|
|
|
|
manifest located at: [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
2017-05-26 21:00:45 +00:00
|
|
|
|
fn virtual_build_all_implied() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-10-21 03:57:51 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-10-21 03:57:51 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-10-21 03:57:51 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2016-10-21 03:57:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-23 15:01:29 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn virtual_default_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:01:29 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar", "baz"]
|
|
|
|
|
default-members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:01:29 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:01:29 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-11-23 15:01:29 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("baz/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2017-11-23 15:01:29 +00:00
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
assert_that(&p.bin("baz"), is_not(existing_file()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn virtual_default_member_is_not_a_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:01:29 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
|
|
|
|
default-members = ["something-else"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-11-23 15:01:29 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-11-23 15:01:29 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2017-11-23 15:01:29 +00:00
|
|
|
|
error: package `[..]something-else` is listed in workspace’s default-members \
|
|
|
|
|
but is not a member.
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2017-11-23 15:01:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-21 03:57:51 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn virtual_build_no_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project().file(
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2017-09-14 11:52:06 +00:00
|
|
|
|
error: manifest path `[..]` contains no package: The manifest is virtual, \
|
|
|
|
|
and the workspace has no members.
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn include_virtual() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/main.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
error: multiple workspace roots found in the same workspace:
|
|
|
|
|
[..]
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn members_include_path_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["p1"]
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
p3 = { path = "p3" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"p1/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "p1"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
p2 = { path = "../p2" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("p1/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"p2/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "p2"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("p2/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"p3/Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "p3"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("p3/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("p1")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("p2")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("p3")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("target"), existing_dir());
|
|
|
|
|
assert_that(&p.root().join("p1/target"), is_not(existing_dir()));
|
|
|
|
|
assert_that(&p.root().join("p2/target"), is_not(existing_dir()));
|
|
|
|
|
assert_that(&p.root().join("p3/target"), is_not(existing_dir()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn new_warns_you_this_will_not_work() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-05-15 00:14:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-05-15 00:14:24 +00:00
|
|
|
|
.file("src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-05-15 00:14:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("new").arg("--lib").arg("bar").env("USER", "foo"),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2016-05-15 00:14:24 +00:00
|
|
|
|
warning: compiling this new crate may not work due to invalid workspace \
|
|
|
|
|
configuration
|
|
|
|
|
|
|
|
|
|
current package believes it's in a workspace when it's not:
|
|
|
|
|
current: [..]
|
|
|
|
|
workspace: [..]
|
|
|
|
|
|
|
|
|
|
this may be fixable by ensuring that this crate is depended on by the workspace \
|
|
|
|
|
root: [..]
|
2016-07-29 19:52:33 +00:00
|
|
|
|
[CREATED] library `bar` project
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2016-05-15 00:14:24 +00:00
|
|
|
|
}
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn lock_doesnt_change_depending_on_crate() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-07-08 06:11:22 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ['baz']
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
foo = "*"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-07-08 06:11:22 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2016-07-08 06:11:22 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = "*"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-07-08 06:11:22 +00:00
|
|
|
|
.file("baz/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
Package::new("foo", "1.0.0").publish();
|
|
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
let mut lockfile = String::new();
|
|
|
|
|
t!(t!(File::open(p.root().join("Cargo.lock"))).read_to_string(&mut lockfile));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("baz")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-07-08 06:11:22 +00:00
|
|
|
|
|
|
|
|
|
let mut lockfile2 = String::new();
|
|
|
|
|
t!(t!(File::open(p.root().join("Cargo.lock"))).read_to_string(&mut lockfile2));
|
|
|
|
|
|
|
|
|
|
assert_eq!(lockfile, lockfile2);
|
|
|
|
|
}
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn rebuild_please() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ['lib', 'bin']
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"lib/Cargo.toml",
|
|
|
|
|
r#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "lib"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"lib/src/lib.rs",
|
|
|
|
|
r#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
pub fn foo() -> u32 { 0 }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bin/Cargo.toml",
|
|
|
|
|
r#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "bin"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
lib = { path = "../lib" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bin/src/main.rs",
|
|
|
|
|
r#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
extern crate lib;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
assert_eq!(lib::foo(), 0);
|
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("run").cwd(p.root().join("bin")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
|
2016-07-28 17:26:32 +00:00
|
|
|
|
sleep_ms(1000);
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
t!(t!(File::create(p.root().join("lib/src/lib.rs"))).write_all(
|
|
|
|
|
br#"
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
pub fn foo() -> u32 { 1 }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("lib")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("run").cwd(p.root().join("bin")),
|
|
|
|
|
execs().with_status(101),
|
|
|
|
|
);
|
Always build libraries into the same location
Previously Cargo would compile a library into a different location depending on
whether it was the "root crate" or not. In the ongoing saga of reducing Cargo's
reliance on the idea of a "root crate" this PR is the next step. With workspaces
the root crate of a compliation changes all the time, so the output needs to be
the same whether a crate is at the root or not.
Fixing this inconsistence in turn fixes bugs like #2855 and #2897 which arise
due to this discrepancy. Additionally, Cargo will no longer recompile a library
when it's used as a "root crate" or not.
This is fixed by taking a few steps:
* Everything is now compiled into the `deps` directory, regardless of whether
it's a root output or not.
* If a "root crate" is being compiled, then the relevant outputs are hard-linked
up one level to where they are today. This means that your binaries, dylibs,
staticlibs, etc, will all show up where they used to.
* The `-C metadata` flag is always omitted for path dependencies now. These
dependencies are always path dependencies and already all have unique crate
names. Additionally, they're the only crates in the DAG without metadata, so
there's no need to provide additional metadata. This in turn means that none
of the file names of the generated crates are mangled.
Closes #2855
2016-07-25 20:27:06 +00:00
|
|
|
|
}
|
2016-07-31 23:35:52 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn workspace_in_git() {
|
|
|
|
|
let git_project = git::new("dep1", |project| {
|
|
|
|
|
project
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-07-31 23:35:52 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2016-07-31 23:35:52 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-07-31 23:35:52 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
|
|
|
|
}).unwrap();
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
2016-07-31 23:35:52 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "lib"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies.foo]
|
|
|
|
|
git = '{}'
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
git_project.url()
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"src/lib.rs",
|
|
|
|
|
r#"
|
2016-07-31 23:35:52 +00:00
|
|
|
|
pub fn foo() -> u32 { 0 }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-07-31 23:35:52 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2016-07-31 23:35:52 +00:00
|
|
|
|
}
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn lockfile_can_specify_nonexistant_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-08-25 10:10:45 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"a/Cargo.toml",
|
|
|
|
|
r#"
|
2016-08-25 10:10:45 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "a"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-08-25 10:10:45 +00:00
|
|
|
|
.file("a/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.lock",
|
|
|
|
|
r#"
|
2017-10-03 12:18:08 +00:00
|
|
|
|
[[package]]
|
2016-08-25 10:10:45 +00:00
|
|
|
|
name = "a"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[[package]]
|
|
|
|
|
name = "b"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
);
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-08-25 10:10:45 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("a")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2016-08-25 10:10:45 +00:00
|
|
|
|
}
|
2016-09-14 19:02:47 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn you_cannot_generate_lockfile_for_empty_workspaces() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-09-14 19:02:47 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-09-14 19:02:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-09-14 19:02:47 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-09-14 19:02:47 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("update"),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("error: you can't generate a lockfile for an empty workspace."),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2016-09-14 19:02:47 +00:00
|
|
|
|
}
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn workspace_with_transitive_dev_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2016-09-26 21:13:49 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.5.0"
|
|
|
|
|
authors = ["mbrubeck@example.com"]
|
|
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
|
path = "bar"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-09-26 21:13:49 +00:00
|
|
|
|
.file("src/main.rs", r#"fn main() {}"#)
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-09-26 21:13:49 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.5.0"
|
|
|
|
|
authors = ["mbrubeck@example.com"]
|
|
|
|
|
|
|
|
|
|
[dev-dependencies.baz]
|
|
|
|
|
path = "../baz"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/src/lib.rs",
|
|
|
|
|
r#"
|
2016-09-26 21:13:49 +00:00
|
|
|
|
pub fn init() {}
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test() {
|
|
|
|
|
extern crate baz;
|
|
|
|
|
baz::do_stuff();
|
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"baz/Cargo.toml",
|
|
|
|
|
r#"
|
2016-09-26 21:13:49 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.5.0"
|
|
|
|
|
authors = ["mbrubeck@example.com"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-09-26 21:13:49 +00:00
|
|
|
|
.file("baz/src/lib.rs", r#"pub fn do_stuff() {}"#);
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-09-26 21:13:49 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("test").args(&["-p", "bar"]), execs().with_status(0));
|
2016-09-26 21:13:49 +00:00
|
|
|
|
}
|
2016-12-15 17:27:48 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn error_if_parent_cargo_toml_is_invalid() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2016-12-15 17:27:48 +00:00
|
|
|
|
.file("Cargo.toml", "Totally not a TOML file")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2016-12-15 17:27:48 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-12-15 17:27:48 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-12-15 17:27:48 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("bar")),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr_contains("[ERROR] failed to parse manifest at `[..]`"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2016-12-15 17:27:48 +00:00
|
|
|
|
}
|
2017-01-03 11:11:57 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn relative_path_for_member_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-03 11:11:57 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["../bar"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-01-03 11:11:57 +00:00
|
|
|
|
.file("foo/src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-03 11:11:57 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../foo"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-01-03 11:11:57 +00:00
|
|
|
|
.file("bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-03 11:11:57 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
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),
|
|
|
|
|
);
|
2016-12-22 17:56:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-14 20:04:24 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn relative_path_for_root_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-02-14 20:04:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
subproj = { path = "./subproj" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-02-14 20:04:24 +00:00
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"subproj/Cargo.toml",
|
|
|
|
|
r#"
|
2017-02-14 20:04:24 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "subproj"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-02-14 20:04:24 +00:00
|
|
|
|
.file("subproj/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-02-14 20:04:24 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build")
|
|
|
|
|
.cwd(p.root())
|
|
|
|
|
.arg("--manifest-path")
|
|
|
|
|
.arg("./Cargo.toml"),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build")
|
|
|
|
|
.cwd(p.root().join("subproj"))
|
|
|
|
|
.arg("--manifest-path")
|
|
|
|
|
.arg("../Cargo.toml"),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-02-14 20:04:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-22 17:56:40 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn path_dep_outside_workspace_is_not_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2016-12-22 17:56:40 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-12-22 17:56:40 +00:00
|
|
|
|
.file("ws/src/lib.rs", r"extern crate foo;")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2016-12-22 17:56:40 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2016-12-22 17:56:40 +00:00
|
|
|
|
.file("foo/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2016-12-22 17:56:40 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("ws")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-01-14 22:14:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_in_and_out_of_workspace() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = [ "../bar" ]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"ws/src/lib.rs",
|
|
|
|
|
r"extern crate foo; pub fn f() { foo::f() }",
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "../bar" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/src/lib.rs",
|
|
|
|
|
"extern crate bar; pub fn f() { bar::f() }",
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
workspace = "../ws"
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-01-14 22:14:47 +00:00
|
|
|
|
.file("bar/src/lib.rs", "pub fn f() { }");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("ws")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("ws/Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("ws/target"), existing_dir());
|
|
|
|
|
assert_that(&p.root().join("foo/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("foo/target"), is_not(existing_dir()));
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-01-14 22:14:47 +00:00
|
|
|
|
assert_that(&p.root().join("foo/Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("foo/target"), existing_dir());
|
|
|
|
|
assert_that(&p.root().join("bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("bar/target"), is_not(existing_dir()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_path_dependency_under_member() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"ws/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
foo = { path = "../foo" }
|
|
|
|
|
|
2017-01-16 23:05:32 +00:00
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"ws/src/lib.rs",
|
|
|
|
|
r"extern crate foo; pub fn f() { foo::f() }",
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
workspace = "../ws"
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "./bar" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/src/lib.rs",
|
|
|
|
|
"extern crate bar; pub fn f() { bar::f() }",
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"foo/bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-01-14 22:14:47 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-01-14 22:14:47 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "pub fn f() { }");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("ws")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-01-14 22:14:47 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
&p.root().join("foo/bar/Cargo.lock"),
|
|
|
|
|
is_not(existing_file()),
|
|
|
|
|
);
|
2017-01-14 22:14:47 +00:00
|
|
|
|
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo/bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-01-16 22:30:59 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
&p.root().join("foo/bar/Cargo.lock"),
|
|
|
|
|
is_not(existing_file()),
|
|
|
|
|
);
|
2017-01-16 22:30:59 +00:00
|
|
|
|
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
|
2017-01-14 22:14:47 +00:00
|
|
|
|
}
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn excluded_simple() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
exclude = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("target"), existing_dir());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("foo/target"), existing_dir());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn exclude_members_preferred() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo/bar"]
|
|
|
|
|
exclude = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("target"), existing_dir());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("foo/target"), existing_dir());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo/bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("foo/bar/target"), is_not(existing_dir()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn exclude_but_also_depend() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "ws"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
bar = { path = "foo/bar" }
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
exclude = ["foo"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"foo/bar/Cargo.toml",
|
|
|
|
|
r#"
|
2017-03-16 21:50:23 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-03-16 21:50:23 +00:00
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-03-16 21:50:23 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("target"), existing_dir());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("foo/target"), existing_dir());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("foo/bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-03-16 21:50:23 +00:00
|
|
|
|
assert_that(&p.root().join("foo/bar/target"), existing_dir());
|
|
|
|
|
}
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn glob_syntax() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2017-04-29 02:08:07 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/*"]
|
|
|
|
|
exclude = ["crates/qux"]
|
|
|
|
|
"#)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/bar/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/baz/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/qux/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "qux"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/qux/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-04-29 02:08:07 +00:00
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.bin("baz"), is_not(existing_file()));
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("crates/bar")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-04-29 02:08:07 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("crates/baz")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-04-29 02:08:07 +00:00
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("baz"), existing_file());
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("crates/qux")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-04-29 02:08:07 +00:00
|
|
|
|
assert_that(&p.bin("qux"), is_not(existing_file()));
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
&p.root().join("crates/bar/Cargo.lock"),
|
|
|
|
|
is_not(existing_file()),
|
|
|
|
|
);
|
|
|
|
|
assert_that(
|
|
|
|
|
&p.root().join("crates/baz/Cargo.lock"),
|
|
|
|
|
is_not(existing_file()),
|
|
|
|
|
);
|
2017-04-29 02:08:07 +00:00
|
|
|
|
assert_that(&p.root().join("crates/qux/Cargo.lock"), existing_file());
|
|
|
|
|
}
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2017-09-26 05:55:02 +00:00
|
|
|
|
/*FIXME: This fails because of how workspace.exclude and workspace.members are working.
|
|
|
|
|
#[test]
|
|
|
|
|
fn glob_syntax_2() {
|
2018-07-20 14:25:51 +00:00
|
|
|
|
let p = project()
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/b*"]
|
|
|
|
|
exclude = ["crates/q*"]
|
|
|
|
|
"#)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/bar/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/baz/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "baz"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
workspace = "../.."
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/baz/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/qux/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "qux"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#)
|
|
|
|
|
.file("crates/qux/src/main.rs", "fn main() {}");
|
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.bin("baz"), is_not(existing_file()));
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build").cwd(p.root().join("crates/bar")),
|
|
|
|
|
execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("bar"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build").cwd(p.root().join("crates/baz")),
|
|
|
|
|
execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("foo"), existing_file());
|
|
|
|
|
assert_that(&p.bin("baz"), existing_file());
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build").cwd(p.root().join("crates/qux")),
|
|
|
|
|
execs().with_status(0));
|
|
|
|
|
assert_that(&p.bin("qux"), is_not(existing_file()));
|
|
|
|
|
|
|
|
|
|
assert_that(&p.root().join("Cargo.lock"), existing_file());
|
|
|
|
|
assert_that(&p.root().join("crates/bar/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("crates/baz/Cargo.lock"), is_not(existing_file()));
|
|
|
|
|
assert_that(&p.root().join("crates/qux/Cargo.lock"), existing_file());
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2017-05-07 06:33:45 +00:00
|
|
|
|
#[test]
|
2017-05-09 05:30:23 +00:00
|
|
|
|
fn glob_syntax_invalid_members() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2017-05-07 06:33:45 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["crates/*"]
|
|
|
|
|
"#)
|
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
|
.file("crates/bar/src/main.rs", "fn main() {}");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build"),
|
|
|
|
|
execs().with_status(101).with_stderr(
|
|
|
|
|
"\
|
2017-05-09 05:30:23 +00:00
|
|
|
|
error: failed to read `[..]Cargo.toml`
|
2017-05-07 06:33:45 +00:00
|
|
|
|
|
2017-05-09 05:30:23 +00:00
|
|
|
|
Caused by:
|
|
|
|
|
[..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2017-05-07 06:33:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-05 00:13:26 +00:00
|
|
|
|
/// This is a freshness test for feature use with workspaces
|
|
|
|
|
///
|
|
|
|
|
/// feat_lib is used by caller1 and caller2, but with different features enabled.
|
|
|
|
|
/// This test ensures that alternating building caller1, caller2 doesn't force
|
|
|
|
|
/// recompile of feat_lib.
|
|
|
|
|
///
|
|
|
|
|
/// Ideally once we solve https://github.com/rust-lang/cargo/issues/3620, then
|
|
|
|
|
/// a single cargo build at the top level will be enough.
|
|
|
|
|
#[test]
|
|
|
|
|
fn dep_used_with_separate_features() {
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[workspace]
|
|
|
|
|
members = ["feat_lib", "caller1", "caller2"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"feat_lib/Cargo.toml",
|
|
|
|
|
r#"
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "feat_lib"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[features]
|
|
|
|
|
myfeature = []
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-09-05 00:13:26 +00:00
|
|
|
|
.file("feat_lib/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"caller1/Cargo.toml",
|
|
|
|
|
r#"
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "caller1"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
feat_lib = { path = "../feat_lib" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-09-05 00:13:26 +00:00
|
|
|
|
.file("caller1/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("caller1/src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"caller2/Cargo.toml",
|
|
|
|
|
r#"
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[project]
|
|
|
|
|
name = "caller2"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
feat_lib = { path = "../feat_lib", features = ["myfeature"] }
|
|
|
|
|
caller1 = { path = "../caller1" }
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-09-05 00:13:26 +00:00
|
|
|
|
.file("caller2/src/main.rs", "fn main() {}")
|
|
|
|
|
.file("caller2/src/lib.rs", "");
|
2017-07-22 03:12:21 +00:00
|
|
|
|
let p = p.build();
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
|
|
|
|
// Build the entire workspace
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").arg("--all"),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[..]Compiling feat_lib v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller1 v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller2 v0.1.0 ([..])
|
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2017-09-05 00:13:26 +00:00
|
|
|
|
assert_that(&p.bin("caller1"), existing_file());
|
|
|
|
|
assert_that(&p.bin("caller2"), existing_file());
|
|
|
|
|
|
|
|
|
|
// Build caller1. should build the dep library. Because the features
|
|
|
|
|
// are different than the full workspace, it rebuilds.
|
2017-09-05 08:46:22 +00:00
|
|
|
|
// Ideally once we solve https://github.com/rust-lang/cargo/issues/3620, then
|
|
|
|
|
// a single cargo build at the top level will be enough.
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("caller1")),
|
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
|
"\
|
2017-09-05 00:13:26 +00:00
|
|
|
|
[..]Compiling feat_lib v0.1.0 ([..])
|
|
|
|
|
[..]Compiling caller1 v0.1.0 ([..])
|
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
",
|
|
|
|
|
),
|
|
|
|
|
);
|
2017-09-05 00:13:26 +00:00
|
|
|
|
|
|
|
|
|
// Alternate building caller2/caller1 a few times, just to make sure
|
|
|
|
|
// features are being built separately. Should not rebuild anything
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("caller2")),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(0)
|
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("caller1")),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(0)
|
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").cwd(p.root().join("caller2")),
|
2018-03-14 15:43:41 +00:00
|
|
|
|
execs()
|
|
|
|
|
.with_status(0)
|
|
|
|
|
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]"),
|
2018-03-14 15:17:44 +00:00
|
|
|
|
);
|
2017-09-05 00:13:26 +00:00
|
|
|
|
}
|
2017-09-26 05:55:02 +00:00
|
|
|
|
|
2017-12-01 01:32:15 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn dont_recurse_out_of_cargo_home() {
|
|
|
|
|
let git_project = git::new("dep", |project| {
|
|
|
|
|
project
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "dep"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-12-01 01:32:15 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"build.rs",
|
|
|
|
|
r#"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
use std::env;
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
use std::process::{self, Command};
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let cargo = env::var_os("CARGO").unwrap();
|
|
|
|
|
let cargo_manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
|
|
|
|
let output = Command::new(cargo)
|
|
|
|
|
.args(&["metadata", "--format-version", "1", "--manifest-path"])
|
|
|
|
|
.arg(&Path::new(&cargo_manifest_dir).join("Cargo.toml"))
|
|
|
|
|
.output()
|
|
|
|
|
.unwrap();
|
|
|
|
|
if !output.status.success() {
|
|
|
|
|
eprintln!("{}", String::from_utf8(output.stderr).unwrap());
|
|
|
|
|
process::exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-12-01 01:32:15 +00:00
|
|
|
|
}).unwrap();
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
&format!(
|
|
|
|
|
r#"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
[package]
|
2018-07-20 17:41:44 +00:00
|
|
|
|
name = "foo"
|
2017-12-01 01:32:15 +00:00
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies.dep]
|
|
|
|
|
git = "{}"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
git_project.url()
|
|
|
|
|
),
|
|
|
|
|
)
|
2017-12-01 01:32:15 +00:00
|
|
|
|
.file("src/lib.rs", "");
|
|
|
|
|
let p = p.build();
|
|
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").env("CARGO_HOME", p.root().join(".cargo")),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-12-01 01:32:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 05:55:02 +00:00
|
|
|
|
/*FIXME: This fails because of how workspace.exclude and workspace.members are working.
|
|
|
|
|
#[test]
|
|
|
|
|
fn include_and_exclude() {
|
2018-07-20 14:25:51 +00:00
|
|
|
|
let p = project()
|
2017-09-26 05:55:02 +00:00
|
|
|
|
.file("Cargo.toml", r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["foo"]
|
|
|
|
|
exclude = ["foo/bar"]
|
|
|
|
|
"#)
|
|
|
|
|
.file("foo/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#)
|
|
|
|
|
.file("foo/src/lib.rs", "")
|
|
|
|
|
.file("foo/bar/Cargo.toml", r#"
|
|
|
|
|
[project]
|
|
|
|
|
name = "bar"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
authors = []
|
|
|
|
|
"#)
|
|
|
|
|
.file("foo/bar/src/lib.rs", "");
|
|
|
|
|
p.build();
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build").cwd(p.root().join("foo")),
|
|
|
|
|
execs().with_status(0));
|
|
|
|
|
assert_that(&p.root().join("target"), existing_dir());
|
|
|
|
|
assert_that(&p.root().join("foo/target"), is_not(existing_dir()));
|
|
|
|
|
assert_that(p.cargo("build").cwd(p.root().join("foo/bar")),
|
|
|
|
|
execs().with_status(0));
|
|
|
|
|
assert_that(&p.root().join("foo/bar/target"), existing_dir());
|
|
|
|
|
}
|
|
|
|
|
*/
|
2017-12-13 21:19:12 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn cargo_home_at_root_works() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2017-12-13 21:19:12 +00:00
|
|
|
|
[package]
|
2018-07-20 17:41:44 +00:00
|
|
|
|
name = "foo"
|
2017-12-13 21:19:12 +00:00
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-12-13 21:19:12 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"a/Cargo.toml",
|
|
|
|
|
r#"
|
2017-12-13 21:19:12 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "a"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2017-12-13 21:19:12 +00:00
|
|
|
|
.file("a/src/lib.rs", "");
|
|
|
|
|
let p = p.build();
|
|
|
|
|
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("build").arg("--frozen").env("CARGO_HOME", p.root()),
|
|
|
|
|
execs().with_status(0),
|
|
|
|
|
);
|
2017-12-13 21:19:12 +00:00
|
|
|
|
}
|
2018-01-31 18:30:01 +00:00
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn relative_rustc() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2018-01-31 18:30:01 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "foo"
|
|
|
|
|
version = "0.1.0"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file(
|
|
|
|
|
"src/main.rs",
|
|
|
|
|
r#"
|
2018-01-31 18:30:01 +00:00
|
|
|
|
use std::process::Command;
|
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
let mut cmd = Command::new("rustc");
|
|
|
|
|
for arg in env::args_os().skip(1) {
|
|
|
|
|
cmd.arg(arg);
|
|
|
|
|
}
|
|
|
|
|
std::process::exit(cmd.status().unwrap().code().unwrap());
|
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2018-01-31 18:30:01 +00:00
|
|
|
|
.build();
|
|
|
|
|
assert_that(p.cargo("build"), execs().with_status(0));
|
|
|
|
|
|
|
|
|
|
let src = p.root()
|
|
|
|
|
.join("target/debug/foo")
|
|
|
|
|
.with_extension(env::consts::EXE_EXTENSION);
|
|
|
|
|
|
|
|
|
|
Package::new("a", "0.1.0").publish();
|
|
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
|
let p = project().at("lib")
|
2018-03-14 15:17:44 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
2018-01-31 18:30:01 +00:00
|
|
|
|
[package]
|
|
|
|
|
name = "lib"
|
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
|
a = "0.1"
|
2018-03-14 15:17:44 +00:00
|
|
|
|
"#,
|
|
|
|
|
)
|
2018-01-31 18:30:01 +00:00
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
fs::copy(&src, p.root().join(src.file_name().unwrap())).unwrap();
|
|
|
|
|
|
|
|
|
|
let file = format!("./foo{}", env::consts::EXE_SUFFIX);
|
2018-03-14 15:17:44 +00:00
|
|
|
|
assert_that(p.cargo("build").env("RUSTC", &file), execs().with_status(0));
|
2018-01-31 18:30:01 +00:00
|
|
|
|
}
|
2018-05-01 03:39:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn ws_rustc_err() {
|
2018-07-20 17:41:44 +00:00
|
|
|
|
let p = project()
|
2018-05-01 03:39:07 +00:00
|
|
|
|
.file(
|
|
|
|
|
"Cargo.toml",
|
|
|
|
|
r#"
|
|
|
|
|
[workspace]
|
|
|
|
|
members = ["a"]
|
|
|
|
|
"#,
|
|
|
|
|
)
|
|
|
|
|
.file("a/Cargo.toml", &basic_lib_manifest("a"))
|
|
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("rustc"),
|
|
|
|
|
execs()
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("[ERROR] [..]against an actual package[..]"),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
|
p.cargo("rustdoc"),
|
|
|
|
|
execs()
|
|
|
|
|
.with_status(101)
|
|
|
|
|
.with_stderr("[ERROR] [..]against an actual package[..]"),
|
|
|
|
|
);
|
|
|
|
|
}
|