2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for profiles.
|
|
|
|
|
2022-01-14 18:57:54 +00:00
|
|
|
use cargo_test_support::project;
|
2022-02-22 18:50:18 +00:00
|
|
|
use cargo_test_support::registry::Package;
|
2021-09-09 06:10:33 +00:00
|
|
|
use std::env;
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn profile_overrides() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "test"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
opt-level = 1
|
|
|
|
debug = false
|
|
|
|
rpath = true
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] test v0.0.0 ([CWD])
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
|
2020-04-01 18:41:27 +00:00
|
|
|
--emit=[..]link[..]\
|
|
|
|
-C opt-level=1[..]\
|
2015-03-24 00:45:41 +00:00
|
|
|
-C debug-assertions=on \
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
2014-10-15 17:28:15 +00:00
|
|
|
-C rpath \
|
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 [..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
-L dependency=[CWD]/target/debug/deps`
|
2017-01-12 01:03:36 +00:00
|
|
|
[FINISHED] dev [optimized] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-17 07:35:57 +00:00
|
|
|
fn opt_level_override_0() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2016-08-17 07:35:57 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "test"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2016-08-17 07:35:57 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
opt-level = 0
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] test v0.0.0 ([CWD])
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
|
2020-04-01 18:41:27 +00:00
|
|
|
--emit=[..]link[..]\
|
2023-05-31 10:09:35 +00:00
|
|
|
-C debuginfo=2 [..]\
|
2017-01-12 05:35:17 +00:00
|
|
|
-C metadata=[..] \
|
|
|
|
--out-dir [..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
-L dependency=[CWD]/target/debug/deps`
|
2017-01-12 05:35:17 +00:00
|
|
|
[FINISHED] [..] target(s) in [..]
|
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2017-01-12 05:35:17 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2017-01-12 05:35:17 +00:00
|
|
|
fn debug_override_1() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "test"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2017-01-12 05:35:17 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
debug = 1
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
2018-09-03 09:38:29 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] test v0.0.0 ([CWD])
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
|
2020-04-01 18:41:27 +00:00
|
|
|
--emit=[..]link[..]\
|
2023-05-31 10:09:35 +00:00
|
|
|
-C debuginfo=1 [..]\
|
2016-08-17 07:35:57 +00:00
|
|
|
-C metadata=[..] \
|
|
|
|
--out-dir [..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
-L dependency=[CWD]/target/debug/deps`
|
2016-08-17 07:35:57 +00:00
|
|
|
[FINISHED] [..] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-08-17 07:35:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2016-08-17 07:35:57 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "test"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2016-08-17 07:35:57 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
opt-level = {level}
|
|
|
|
"#,
|
2018-03-14 15:17:44 +00:00
|
|
|
level = profile_level
|
|
|
|
),
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] test v0.0.0 ([CWD])
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
|
2019-04-26 20:53:51 +00:00
|
|
|
--emit=[..]link \
|
2020-04-01 18:41:27 +00:00
|
|
|
-C opt-level={level}[..]\
|
2023-05-31 10:09:35 +00:00
|
|
|
-C debuginfo=2 [..]\
|
2016-08-17 07:35:57 +00:00
|
|
|
-C debug-assertions=on \
|
|
|
|
-C metadata=[..] \
|
|
|
|
--out-dir [..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
-L dependency=[CWD]/target/debug/deps`
|
2016-08-17 07:35:57 +00:00
|
|
|
[FINISHED] [..] target(s) in [..]
|
2016-11-06 04:53:21 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
level = rustc_level
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.run();
|
2016-08-17 07:35:57 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-08-17 07:35:57 +00:00
|
|
|
fn opt_level_overrides() {
|
|
|
|
for &(profile_level, rustc_level) in &[
|
|
|
|
("1", "1"),
|
|
|
|
("2", "2"),
|
|
|
|
("3", "3"),
|
|
|
|
("\"s\"", "s"),
|
|
|
|
("\"z\"", "z"),
|
|
|
|
] {
|
|
|
|
check_opt_level_override(profile_level, rustc_level)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn top_level_overrides_deps() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "test"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release]
|
|
|
|
opt-level = 1
|
|
|
|
debug = true
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies.foo]
|
|
|
|
path = "foo"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"foo/Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.0.0"
|
|
|
|
authors = []
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release]
|
|
|
|
opt-level = 0
|
|
|
|
debug = false
|
2014-09-03 18:34:26 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[lib]
|
|
|
|
name = "foo"
|
|
|
|
crate_type = ["dylib", "rlib"]
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("foo/src/lib.rs", "")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v --release")
|
|
|
|
.with_stderr(&format!(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2018-09-08 02:42:26 +00:00
|
|
|
[COMPILING] foo v0.0.0 ([CWD]/foo)
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo foo/src/lib.rs [..]\
|
2017-01-03 21:22:58 +00:00
|
|
|
--crate-type dylib --crate-type rlib \
|
2019-04-26 20:53:51 +00:00
|
|
|
--emit=[..]link \
|
2017-01-03 21:22:58 +00:00
|
|
|
-C prefer-dynamic \
|
2020-04-01 18:41:27 +00:00
|
|
|
-C opt-level=1[..]\
|
2023-05-31 10:09:35 +00:00
|
|
|
-C debuginfo=2 [..]\
|
2016-08-02 06:22:29 +00:00
|
|
|
-C metadata=[..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
--out-dir [CWD]/target/release/deps \
|
|
|
|
-L dependency=[CWD]/target/release/deps`
|
|
|
|
[COMPILING] test v0.0.0 ([CWD])
|
2019-09-25 01:17:36 +00:00
|
|
|
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
|
2019-04-26 20:53:51 +00:00
|
|
|
--emit=[..]link \
|
2020-04-01 18:41:27 +00:00
|
|
|
-C opt-level=1[..]\
|
2023-05-31 10:09:35 +00:00
|
|
|
-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 [..] \
|
2018-09-08 02:42:26 +00:00
|
|
|
-L dependency=[CWD]/target/release/deps \
|
|
|
|
--extern foo=[CWD]/target/release/deps/\
|
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
|
|
|
{prefix}foo[..]{suffix} \
|
2018-09-08 02:42:26 +00:00
|
|
|
--extern foo=[CWD]/target/release/deps/libfoo.rlib`
|
2016-07-25 23:30:03 +00:00
|
|
|
[FINISHED] release [optimized + debuginfo] target(s) in [..]
|
2014-09-11 14:35:01 +00:00
|
|
|
",
|
2018-03-14 15:17:44 +00:00
|
|
|
prefix = env::consts::DLL_PREFIX,
|
|
|
|
suffix = env::consts::DLL_SUFFIX
|
2018-12-08 11:19:47 +00:00
|
|
|
))
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-11-02 15:16:44 +00:00
|
|
|
fn profile_in_non_root_manifest_triggers_a_warning() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
debug = false
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
workspace = ".."
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
opt-level = 1
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
2019-03-20 23:34:56 +00:00
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-11-02 15:16:44 +00:00
|
|
|
[WARNING] profiles for the non root package will be ignored, specify profiles at the workspace root:
|
|
|
|
package: [..]
|
|
|
|
workspace: [..]
|
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
|
|
|
[RUNNING] `rustc [..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
[FINISHED] dev [unoptimized] target(s) in [..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-11-02 15:16:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-11-02 15:16:44 +00:00
|
|
|
fn profile_in_virtual_manifest_works() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[workspace]
|
|
|
|
members = ["bar"]
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
opt-level = 1
|
|
|
|
debug = false
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "bar"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
workspace = ".."
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("bar/src/main.rs", "fn main() {}")
|
2017-07-22 03:12:21 +00:00
|
|
|
.build();
|
2016-11-02 15:16:44 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build -v")
|
2019-03-20 23:34:56 +00:00
|
|
|
.cwd("bar")
|
2018-08-28 09:20:03 +00:00
|
|
|
.with_stderr(
|
2018-03-14 15:17:44 +00:00
|
|
|
"\
|
2016-11-02 15:16:44 +00:00
|
|
|
[COMPILING] bar v0.1.0 ([..])
|
|
|
|
[RUNNING] `rustc [..]`
|
2018-03-14 15:17:44 +00:00
|
|
|
[FINISHED] dev [optimized] target(s) in [..]",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2016-11-02 15:16:44 +00:00
|
|
|
}
|
2018-04-18 01:46:44 +00:00
|
|
|
|
2022-05-17 18:04:48 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn profile_lto_string_bool_dev() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
lto = "true"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
`lto` setting of string `\"true\"` for `dev` profile is not a valid setting, \
|
|
|
|
must be a boolean (`true`/`false`) or a string (`\"thin\"`/`\"fat\"`/`\"off\"`) or omitted.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-04-21 16:40:00 +00:00
|
|
|
fn profile_panic_test_bench() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-04-21 16:40:00 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2018-04-21 16:40:00 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.test]
|
|
|
|
panic = "abort"
|
2018-04-21 16:40:00 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.bench]
|
|
|
|
panic = "abort"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-04-21 16:40:00 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr_contains(
|
2018-04-21 16:50:55 +00:00
|
|
|
"\
|
2018-04-21 16:40:00 +00:00
|
|
|
[WARNING] `panic` setting is ignored for `bench` profile
|
2019-06-07 17:08:43 +00:00
|
|
|
[WARNING] `panic` setting is ignored for `test` profile
|
2018-04-21 16:50:55 +00:00
|
|
|
",
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.run();
|
2018-04-21 16:50:55 +00:00
|
|
|
}
|
2018-05-05 15:52:19 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-05-05 15:52:19 +00:00
|
|
|
fn profile_doc_deprecated() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-05-05 15:52:19 +00:00
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
2018-05-05 15:52:19 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.doc]
|
|
|
|
opt-level = 0
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
2018-05-05 15:52:19 +00:00
|
|
|
.build();
|
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stderr_contains("[WARNING] profile `doc` is deprecated and has no effect")
|
|
|
|
.run();
|
2018-05-05 15:52:19 +00:00
|
|
|
}
|
2019-03-23 23:58:03 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-03-23 23:58:03 +00:00
|
|
|
fn panic_unwind_does_not_build_twice() {
|
|
|
|
// Check for a bug where `lib` was built twice, once with panic set and
|
|
|
|
// once without. Since "unwind" is the default, they are the same and
|
|
|
|
// should only be built once.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
panic = "unwind"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file("tests/t1.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("test -v --tests --no-run")
|
|
|
|
.with_stderr_unordered(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo src/lib.rs [..] --test [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo src/main.rs [..] --test [..]
|
|
|
|
[RUNNING] `rustc --crate-name t1 tests/t1.rs [..]
|
|
|
|
[FINISHED] [..]
|
2021-10-04 21:52:02 +00:00
|
|
|
[EXECUTABLE] `[..]/target/debug/deps/t1-[..][EXE]`
|
|
|
|
[EXECUTABLE] `[..]/target/debug/deps/foo-[..][EXE]`
|
|
|
|
[EXECUTABLE] `[..]/target/debug/deps/foo-[..][EXE]`
|
2019-03-23 23:58:03 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2019-05-20 20:50:27 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2019-05-20 20:50:27 +00:00
|
|
|
fn debug_0_report() {
|
|
|
|
// The finished line handles 0 correctly.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
debug = 0
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.1.0 [..]
|
2023-05-30 21:47:16 +00:00
|
|
|
[RUNNING] `rustc --crate-name foo src/lib.rs [..]
|
2019-05-20 20:50:27 +00:00
|
|
|
[FINISHED] dev [unoptimized] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
2023-05-30 21:47:16 +00:00
|
|
|
.with_stderr_does_not_contain("-C debuginfo")
|
2019-05-20 20:50:27 +00:00
|
|
|
.run();
|
|
|
|
}
|
2019-11-25 02:42:45 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn thin_lto_works() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2022-09-22 19:50:54 +00:00
|
|
|
[package]
|
2020-09-27 00:59:58 +00:00
|
|
|
name = "top"
|
|
|
|
version = "0.5.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[profile.release]
|
|
|
|
lto = 'thin'
|
|
|
|
"#,
|
2019-11-25 02:42:45 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] top [..]
|
|
|
|
[RUNNING] `rustc [..] -C lto=thin [..]`
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2020-05-18 18:57:12 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn strip_works() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2020-05-18 18:57:12 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release]
|
|
|
|
strip = 'symbols'
|
|
|
|
"#,
|
2020-05-18 18:57:12 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
2021-11-16 23:27:57 +00:00
|
|
|
[RUNNING] `rustc [..] -C strip=symbols [..]`
|
2020-05-18 18:57:12 +00:00
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2020-05-19 18:03:59 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
2021-02-10 00:19:10 +00:00
|
|
|
fn strip_passes_unknown_option_to_rustc() {
|
2020-05-19 18:03:59 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
2020-05-19 18:03:59 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release]
|
2021-02-10 00:19:10 +00:00
|
|
|
strip = 'unknown'
|
2020-09-27 00:59:58 +00:00
|
|
|
"#,
|
2020-05-19 18:03:59 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_status(101)
|
2021-02-10 00:19:10 +00:00
|
|
|
.with_stderr_contains(
|
2020-05-19 18:03:59 +00:00
|
|
|
"\
|
2021-02-10 00:19:10 +00:00
|
|
|
[COMPILING] foo [..]
|
2021-11-16 23:27:57 +00:00
|
|
|
[RUNNING] `rustc [..] -C strip=unknown [..]`
|
|
|
|
error: incorrect value `unknown` for [..] `strip` [..] was expected
|
2021-02-10 00:19:10 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2020-05-19 18:03:59 +00:00
|
|
|
|
2021-02-10 00:19:10 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn strip_accepts_true_to_strip_symbols() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.release]
|
|
|
|
strip = true
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
2021-11-16 23:27:57 +00:00
|
|
|
[RUNNING] `rustc [..] -C strip=symbols [..]`
|
2021-02-10 00:19:10 +00:00
|
|
|
[FINISHED] [..]
|
2020-05-19 18:03:59 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2021-02-10 00:19:10 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn strip_accepts_false_to_disable_strip() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.release]
|
|
|
|
strip = false
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
2024-01-06 16:17:51 +00:00
|
|
|
.with_stderr_does_not_contain("[RUNNING] `rustc [..] -C strip[..]`")
|
2021-02-10 00:19:10 +00:00
|
|
|
.run();
|
|
|
|
}
|
2021-12-19 03:31:32 +00:00
|
|
|
|
2024-01-06 16:22:10 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn strip_debuginfo_in_release() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_stderr_contains("[RUNNING] `rustc [..] -C strip=debuginfo[..]`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn strip_debuginfo_without_debug() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
debug = 0
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
|
|
|
.with_stderr_contains("[RUNNING] `rustc [..] -C strip=debuginfo[..]`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn do_not_strip_debuginfo_with_requested_debug() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = { path = "bar" }
|
|
|
|
|
|
|
|
[profile.release.package.bar]
|
|
|
|
debug = 1
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.file(
|
|
|
|
"bar/Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "bar"
|
2024-01-24 09:07:46 +00:00
|
|
|
version = "0.1.0"
|
2024-01-06 16:22:10 +00:00
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("bar/src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release -v")
|
|
|
|
.with_stderr_does_not_contain("[RUNNING] `rustc [..] -C strip=debuginfo[..]`")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2021-12-19 03:31:32 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn rustflags_works() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["profile-rustflags"]
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
rustflags = ["-C", "link-dead-code=yes"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
2021-12-19 03:31:32 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustflags_works_with_env() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
cargo-features = ["profile-rustflags"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
|
|
|
.env("CARGO_PROFILE_DEV_RUSTFLAGS", "-C link-dead-code=yes")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
2021-12-19 03:31:32 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn rustflags_requires_cargo_feature() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[profile.dev]
|
|
|
|
rustflags = ["-C", "link-dead-code=yes"]
|
|
|
|
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
2021-12-19 03:31:32 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
|
|
|
|
|
2022-02-22 18:50:18 +00:00
|
|
|
Caused by:
|
|
|
|
feature `profile-rustflags` is required
|
|
|
|
|
|
|
|
The package requires the Cargo feature called `profile-rustflags`, but that feature is \
|
|
|
|
not stabilized in this version of Cargo (1.[..]).
|
|
|
|
Consider adding `cargo-features = [\"profile-rustflags\"]` to the top of Cargo.toml \
|
|
|
|
(above the [package] table) to tell Cargo you are opting in to use this unstable feature.
|
|
|
|
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-rustflags-option \
|
|
|
|
for more information about the status of this feature.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Package::new("bar", "1.0.0").publish();
|
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
|
|
|
|
[dependencies]
|
|
|
|
bar = "1.0"
|
|
|
|
|
|
|
|
[profile.dev.package.bar]
|
|
|
|
rustflags = ["-C", "link-dead-code=yes"]
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
p.cargo("check")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["profile-rustflags"])
|
2022-02-22 18:50:18 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: failed to parse manifest at `[ROOT]/foo/Cargo.toml`
|
|
|
|
|
2021-12-19 03:31:32 +00:00
|
|
|
Caused by:
|
|
|
|
feature `profile-rustflags` is required
|
|
|
|
|
|
|
|
The package requires the Cargo feature called `profile-rustflags`, but that feature is \
|
|
|
|
not stabilized in this version of Cargo (1.[..]).
|
|
|
|
Consider adding `cargo-features = [\"profile-rustflags\"]` to the top of Cargo.toml \
|
|
|
|
(above the [package] table) to tell Cargo you are opting in to use this unstable feature.
|
|
|
|
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#profile-rustflags-option \
|
|
|
|
for more information about the status of this feature.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2023-04-23 22:16:36 +00:00
|
|
|
|
2023-09-01 15:19:47 +00:00
|
|
|
#[cargo_test]
|
2023-04-23 22:16:36 +00:00
|
|
|
fn debug_options_valid() {
|
2023-05-30 21:47:16 +00:00
|
|
|
let build = |option| {
|
2023-04-23 22:16:36 +00:00
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
authors = []
|
|
|
|
version = "0.0.0"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
debug = "{option}"
|
|
|
|
"#
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build -v")
|
2023-05-30 21:47:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (option, cli) in [
|
|
|
|
("line-directives-only", "line-directives-only"),
|
|
|
|
("line-tables-only", "line-tables-only"),
|
|
|
|
("limited", "1"),
|
|
|
|
("full", "2"),
|
|
|
|
] {
|
|
|
|
build(option)
|
2023-04-23 22:16:36 +00:00
|
|
|
.with_stderr_contains(&format!("[RUNNING] `rustc [..]-C debuginfo={cli} [..]"))
|
|
|
|
.run();
|
|
|
|
}
|
2023-05-30 21:47:16 +00:00
|
|
|
build("none")
|
|
|
|
.with_stderr_does_not_contain("[..]-C debuginfo[..]")
|
|
|
|
.run();
|
2023-04-23 22:16:36 +00:00
|
|
|
}
|