2018-05-09 00:23:28 +00:00
|
|
|
use cargotest::support::{basic_bin_manifest, basic_lib_manifest, execs, project};
|
2016-01-13 01:37:57 +00:00
|
|
|
use hamcrest::assert_that;
|
2015-05-01 21:19:43 +00:00
|
|
|
|
2016-05-12 17:06:36 +00:00
|
|
|
const CARGO_RUSTC_ERROR: &'static str =
|
2018-03-14 15:17:44 +00:00
|
|
|
"[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering
|
2016-05-12 17:06:36 +00:00
|
|
|
the package by passing e.g. `--lib` or `--bin NAME` to specify a single target";
|
2015-05-06 10:08:43 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_lib_for_foo() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-01 21:19:43 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-01 21:19:43 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 21:19:43 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc").arg("--lib").arg("-v"),
|
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
2017-01-03 21:22:58 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
|
2017-01-12 05:35:17 +00:00
|
|
|
--emit=dep-info,link -C debuginfo=2 \
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
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
|
|
|
--out-dir [..] \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
dir = p.root().display(),
|
|
|
|
url = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn lib() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-01 23:01:30 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-01 23:01:30 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc")
|
|
|
|
.arg("--lib")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("--")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("debug-assertions=off"),
|
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
2017-01-03 21:22:58 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib \
|
2017-01-12 05:35:17 +00:00
|
|
|
--emit=dep-info,link -C debuginfo=2 \
|
2016-05-20 16:23:50 +00:00
|
|
|
-C debug-assertions=off \
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
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
|
|
|
--out-dir [..] \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
dir = p.root().display(),
|
|
|
|
url = p.url()
|
|
|
|
)),
|
|
|
|
)
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_main_and_allow_unstable_options() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-01 23:01:30 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-01 23:01:30 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-01 23:01:30 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
2018-03-16 17:03:27 +00:00
|
|
|
p.cargo("rustc -v --bin foo -- -C debug-assertions"),
|
2018-03-14 15:17:44 +00:00
|
|
|
execs().with_status(0).with_stderr(&format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] {name} v{version} ({url})
|
2017-01-03 21:22:58 +00:00
|
|
|
[RUNNING] `rustc --crate-name {name} src[/]lib.rs --crate-type lib \
|
2017-01-12 05:35:17 +00:00
|
|
|
--emit=dep-info,link -C debuginfo=2 \
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
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
|
|
|
--out-dir [..] \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps`
|
2017-01-03 21:22:58 +00:00
|
|
|
[RUNNING] `rustc --crate-name {name} src[/]main.rs --crate-type bin \
|
2017-01-12 05:35:17 +00:00
|
|
|
--emit=dep-info,link -C debuginfo=2 \
|
2016-05-20 16:23:50 +00:00
|
|
|
-C debug-assertions \
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
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
|
|
|
--out-dir [..] \
|
2016-11-06 04:53:21 +00:00
|
|
|
-L dependency={dir}[/]target[/]debug[/]deps \
|
2016-10-04 23:16:30 +00:00
|
|
|
--extern {name}={dir}[/]target[/]debug[/]deps[/]lib{name}-[..].rlib`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
dir = p.root().display(),
|
|
|
|
url = p.url(),
|
|
|
|
name = "foo",
|
|
|
|
version = "0.0.1"
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 14:30:16 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn fails_when_trying_to_build_main_and_lib_with_args() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 14:30:16 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2015-05-02 22:49:58 +00:00
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-02 14:30:16 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 14:30:16 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("--")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("debug-assertions"),
|
|
|
|
execs().with_status(101).with_stderr(CARGO_RUSTC_ERROR),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_with_args_to_one_of_multiple_binaries() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/foo.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/bar.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/baz.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
2018-03-16 17:03:27 +00:00
|
|
|
p.cargo("rustc -v --bin bar -- -C debug-assertions"),
|
2018-03-14 15:17:44 +00:00
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link \
|
|
|
|
-C debuginfo=2 -C metadata=[..] \
|
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
|
|
|
--out-dir [..]`
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `rustc --crate-name bar src[/]bin[/]bar.rs --crate-type bin --emit=dep-info,link \
|
|
|
|
-C debuginfo=2 -C debug-assertions [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
url = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn fails_with_args_to_all_binaries() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/foo.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/bar.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/bin/baz.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("--")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("debug-assertions"),
|
|
|
|
execs().with_status(101).with_stderr(CARGO_RUSTC_ERROR),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_with_args_to_one_of_multiple_tests() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2015-05-02 23:11:46 +00:00
|
|
|
.file("tests/foo.rs", r#" "#)
|
|
|
|
.file("tests/bar.rs", r#" "#)
|
|
|
|
.file("tests/baz.rs", r#" "#)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/lib.rs", r#" "#)
|
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
2018-03-16 17:03:27 +00:00
|
|
|
p.cargo("rustc -v --test bar -- -C debug-assertions"),
|
2018-03-14 15:17:44 +00:00
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link \
|
|
|
|
-C debuginfo=2 -C metadata=[..] \
|
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
|
|
|
--out-dir [..]`
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `rustc --crate-name bar tests[/]bar.rs --emit=dep-info,link -C debuginfo=2 \
|
2016-05-20 16:23:50 +00:00
|
|
|
-C debug-assertions [..]--test[..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
url = p.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_foo_with_bar_dependency() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
extern crate bar;
|
|
|
|
fn main() {
|
|
|
|
bar::baz()
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-07-20 11:47:47 +00:00
|
|
|
let _bar = project().at("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
pub fn baz() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
foo.cargo("rustc")
|
|
|
|
.arg("-v")
|
|
|
|
.arg("--")
|
|
|
|
.arg("-C")
|
|
|
|
.arg("debug-assertions"),
|
|
|
|
execs().with_status(0).with_stderr(format!(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `[..] -C debuginfo=2 [..]`
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] foo v0.0.1 ({url})
|
2017-01-12 05:35:17 +00:00
|
|
|
[RUNNING] `[..] -C debuginfo=2 -C debug-assertions [..]`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
url = foo.url()
|
|
|
|
)),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn build_only_bar_dependency() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
extern crate bar;
|
|
|
|
fn main() {
|
|
|
|
bar::baz()
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-07-20 11:47:47 +00:00
|
|
|
let _bar = project().at("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/lib.rs",
|
|
|
|
r#"
|
2015-05-02 23:11:46 +00:00
|
|
|
pub fn baz() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-05-02 23:11:46 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
2018-03-16 17:03:27 +00:00
|
|
|
foo.cargo("rustc -v -p bar -- -C debug-assertions"),
|
2018-03-14 15:17:44 +00:00
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
2016-05-11 16:55:43 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
2016-11-30 20:05:23 +00:00
|
|
|
[RUNNING] `rustc --crate-name bar [..] --crate-type lib [..] -C debug-assertions [..]`
|
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-25 20:55:42 +00:00
|
|
|
}
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2018-03-15 15:20:15 +00:00
|
|
|
#[test]
|
2018-03-19 17:20:54 +00:00
|
|
|
fn targets_selected_default() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-15 15:20:15 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
assert_that(
|
2018-03-19 17:20:54 +00:00
|
|
|
p.cargo("rustc").arg("-v"),
|
2018-03-15 15:20:15 +00:00
|
|
|
execs().with_status(0)
|
|
|
|
// bin
|
|
|
|
.with_stderr_contains("\
|
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
|
|
|
--emit=dep-info,link[..]")
|
|
|
|
// bench
|
2018-03-19 17:20:54 +00:00
|
|
|
.with_stderr_does_not_contain("\
|
2018-03-15 15:20:15 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
|
|
|
-C opt-level=3 --test [..]")
|
|
|
|
// unit test
|
2018-03-19 17:20:54 +00:00
|
|
|
.with_stderr_does_not_contain("\
|
2018-03-15 15:20:15 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
|
|
|
-C debuginfo=2 --test [..]"),
|
|
|
|
);
|
2018-03-19 17:20:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn targets_selected_all() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-19 17:20:54 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
2018-03-15 15:20:15 +00:00
|
|
|
assert_that(
|
2018-03-19 17:20:54 +00:00
|
|
|
p.cargo("rustc").arg("-v").arg("--all-targets"),
|
2018-03-15 15:20:15 +00:00
|
|
|
execs().with_status(0)
|
|
|
|
// bin
|
|
|
|
.with_stderr_contains("\
|
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin \
|
|
|
|
--emit=dep-info,link[..]")
|
|
|
|
// bench
|
2018-03-19 17:20:54 +00:00
|
|
|
.with_stderr_contains("\
|
2018-03-15 15:20:15 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
|
|
|
-C opt-level=3 --test [..]")
|
|
|
|
// unit test
|
2018-03-19 17:20:54 +00:00
|
|
|
.with_stderr_contains("\
|
2018-03-15 15:20:15 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link \
|
|
|
|
-C debuginfo=2 --test [..]"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn fail_with_multiple_packages() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let foo = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dependencies.bar]
|
|
|
|
path = "../bar"
|
|
|
|
|
|
|
|
[dependencies.baz]
|
|
|
|
path = "../baz"
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
fn main() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let _bar = project().at("bar")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
[package]
|
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
fn main() {
|
|
|
|
if cfg!(flag = "1") { println!("Yeah from bar!"); }
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-15 23:02:37 +00:00
|
|
|
|
2018-07-20 11:47:47 +00:00
|
|
|
let _baz = project().at("baz")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
[package]
|
|
|
|
name = "baz"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-09-12 21:32:35 +00:00
|
|
|
fn main() {
|
|
|
|
if cfg!(flag = "1") { println!("Yeah from baz!"); }
|
|
|
|
}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2015-09-12 21:32:35 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
2018-03-16 17:03:27 +00:00
|
|
|
foo.cargo("rustc -v -p bar -p baz"),
|
2018-03-14 15:17:44 +00:00
|
|
|
execs().with_status(1).with_stderr_contains(
|
|
|
|
"\
|
2018-03-08 18:55:12 +00:00
|
|
|
error: The argument '--package <SPEC>' was provided more than once, \
|
|
|
|
but cannot be used multiple times
|
2018-03-14 15:17:44 +00:00
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-12-17 18:10:59 +00:00
|
|
|
|
2016-05-25 20:55:42 +00:00
|
|
|
#[test]
|
|
|
|
fn rustc_with_other_profile() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2015-12-17 18:10:59 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
a = { path = "a" }
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
2015-12-17 18:10:59 +00:00
|
|
|
#[cfg(test)] extern crate a;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn foo() {}
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"a/Cargo.toml",
|
|
|
|
r#"
|
2015-12-17 18:10:59 +00:00
|
|
|
[package]
|
|
|
|
name = "a"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2018-03-14 15:17:44 +00:00
|
|
|
"#,
|
|
|
|
)
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("a/src/lib.rs", "")
|
|
|
|
.build();
|
2015-12-17 18:10:59 +00:00
|
|
|
|
2018-03-14 15:17:44 +00:00
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc").arg("--profile").arg("test"),
|
|
|
|
execs().with_status(0),
|
|
|
|
);
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2018-04-22 00:21:42 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn rustc_fingerprint() {
|
|
|
|
// Verify that the fingerprint includes the rustc args.
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-22 00:21:42 +00:00
|
|
|
.file("Cargo.toml", &basic_lib_manifest("foo"))
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc -v -- -C debug-assertions"),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc [..]-C debug-assertions [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc -v -- -C debug-assertions"),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc -v"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_does_not_contain("-C debug-assertions")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc -v"),
|
|
|
|
execs().with_status(0).with_stderr(
|
|
|
|
"\
|
|
|
|
[FRESH] foo [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2018-05-09 00:23:28 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn rustc_test_with_implicit_bin() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-09 00:23:28 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
|
|
|
.file(
|
|
|
|
"src/main.rs",
|
|
|
|
r#"
|
|
|
|
#[cfg(foo)]
|
|
|
|
fn f() { compile_fail!("Foo shouldn't be set."); }
|
|
|
|
fn main() {}
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file(
|
|
|
|
"tests/test1.rs",
|
|
|
|
r#"
|
|
|
|
#[cfg(not(foo))]
|
|
|
|
fn f() { compile_fail!("Foo should be set."); } "#,
|
|
|
|
)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
assert_that(
|
|
|
|
p.cargo("rustc --test test1 -v -- --cfg foo"),
|
|
|
|
execs()
|
|
|
|
.with_status(0)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs [..] --cfg foo [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.with_stderr_contains(
|
|
|
|
"\
|
|
|
|
[RUNNING] `rustc --crate-name foo src[/]main.rs [..]
|
|
|
|
",
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|