2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for named profiles.
|
|
|
|
|
2021-07-13 22:22:09 +00:00
|
|
|
use cargo_test_support::paths::CargoPathExt;
|
2019-09-18 05:48:22 +00:00
|
|
|
use cargo_test_support::{basic_lib_manifest, project};
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2019-09-21 06:27:14 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn inherits_on_release() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-21 06:27:14 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release]
|
|
|
|
inherits = "dev"
|
|
|
|
"#,
|
2019-09-21 06:27:14 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2019-12-27 03:59:19 +00:00
|
|
|
[ERROR] `inherits` must not be specified in root profile `release`
|
2019-09-21 06:36:39 +00:00
|
|
|
",
|
2019-09-21 06:27:14 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-09-12 13:27:15 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn missing_inherits() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release-lto]
|
|
|
|
codegen-units = 7
|
|
|
|
"#,
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2019-12-27 03:59:19 +00:00
|
|
|
[ERROR] profile `release-lto` is missing an `inherits` directive \
|
|
|
|
(`inherits` is required for all profiles except `dev` or `release`)
|
|
|
|
",
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-09-21 07:27:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn invalid_profile_name() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-21 07:27:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.'.release-lto']
|
|
|
|
inherits = "release"
|
|
|
|
codegen-units = 7
|
|
|
|
"#,
|
2019-09-21 07:27:51 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] invalid character `.` in profile name: `.release-lto`, allowed characters are letters, numbers, underscore, and hyphen
|
|
|
|
--> Cargo.toml:7:26
|
|
|
|
|
|
|
|
|
7 | [profile.'.release-lto']
|
|
|
|
| ^^^^^^^^^^^^^^
|
|
|
|
|
|
2021-07-13 18:59:15 +00:00
|
|
|
",
|
2019-09-21 07:27:51 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
2022-08-02 19:12:13 +00:00
|
|
|
// We are currently uncertain if dir-name will ever be exposed to the user.
|
|
|
|
// The code for it still roughly exists, but only for the internal profiles.
|
|
|
|
// This test was kept in case we ever want to enable support for it again.
|
|
|
|
#[ignore = "dir-name is disabled"]
|
2019-09-21 07:27:51 +00:00
|
|
|
fn invalid_dir_name() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[profile.'release-lto']
|
|
|
|
inherits = "release"
|
|
|
|
dir-name = ".subdir"
|
|
|
|
codegen-units = 7
|
|
|
|
"#,
|
2019-09-21 07:27:51 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[ERROR] failed to parse manifest at [..]
|
|
|
|
|
|
|
|
Caused by:
|
|
|
|
Invalid character `.` in dir-name: `.subdir`",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2021-07-13 15:21:27 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn dir_name_disabled() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.release-lto]
|
|
|
|
inherits = "release"
|
|
|
|
dir-name = "lto"
|
|
|
|
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:
|
|
|
|
dir-name=\"lto\" in profile `release-lto` is not currently allowed, \
|
|
|
|
directory names are tied to the profile name for custom profiles
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-09-21 07:27:51 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn invalid_inherits() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-21 07:27:51 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.'release-lto']
|
|
|
|
inherits = ".release"
|
|
|
|
codegen-units = 7
|
|
|
|
"#,
|
2019-09-21 07:27:51 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
2021-07-13 18:59:15 +00:00
|
|
|
"error: profile `release-lto` inherits from `.release`, \
|
|
|
|
but that profile is not defined",
|
2019-09-21 07:27:51 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2019-09-12 13:27:15 +00:00
|
|
|
#[cargo_test]
|
|
|
|
fn non_existent_inherits() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release-lto]
|
|
|
|
codegen-units = 7
|
|
|
|
inherits = "non-existent"
|
|
|
|
"#,
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2019-12-27 03:59:19 +00:00
|
|
|
[ERROR] profile `release-lto` inherits from `non-existent`, but that profile is not defined
|
|
|
|
",
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn self_inherits() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release-lto]
|
|
|
|
codegen-units = 7
|
|
|
|
inherits = "release-lto"
|
|
|
|
"#,
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2019-12-27 03:59:19 +00:00
|
|
|
[ERROR] profile inheritance loop detected with profile `release-lto` inheriting `release-lto`
|
|
|
|
",
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn inherits_loop() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release-lto]
|
|
|
|
codegen-units = 7
|
|
|
|
inherits = "release-lto2"
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.release-lto2]
|
|
|
|
codegen-units = 7
|
|
|
|
inherits = "release-lto"
|
|
|
|
"#,
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2019-12-27 03:59:19 +00:00
|
|
|
[ERROR] profile inheritance loop detected with profile `release-lto2` inheriting `release-lto`
|
|
|
|
",
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn overrides_with_custom() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[dependencies]
|
|
|
|
xxx = {path = "xxx"}
|
|
|
|
yyy = {path = "yyy"}
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev]
|
|
|
|
codegen-units = 7
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.dev.package.xxx]
|
|
|
|
codegen-units = 5
|
|
|
|
[profile.dev.package.yyy]
|
|
|
|
codegen-units = 3
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.other]
|
|
|
|
inherits = "dev"
|
|
|
|
codegen-units = 2
|
2019-09-12 13:27:15 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.other.package.yyy]
|
|
|
|
codegen-units = 6
|
|
|
|
"#,
|
2019-09-12 13:27:15 +00:00
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.file("xxx/Cargo.toml", &basic_lib_manifest("xxx"))
|
|
|
|
.file("xxx/src/lib.rs", "")
|
|
|
|
.file("yyy/Cargo.toml", &basic_lib_manifest("yyy"))
|
|
|
|
.file("yyy/src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// profile overrides are inherited between profiles using inherits and have a
|
|
|
|
// higher priority than profile options provided by custom profiles
|
|
|
|
p.cargo("build -v")
|
2019-09-12 14:13:40 +00:00
|
|
|
.with_stderr_unordered(
|
|
|
|
"\
|
2019-09-12 13:27:15 +00:00
|
|
|
[COMPILING] xxx [..]
|
|
|
|
[COMPILING] yyy [..]
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc --crate-name xxx [..] -C codegen-units=5 [..]`
|
|
|
|
[RUNNING] `rustc --crate-name yyy [..] -C codegen-units=3 [..]`
|
|
|
|
[RUNNING] `rustc --crate-name foo [..] -C codegen-units=7 [..]`
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// This also verifies that the custom profile names appears in the finished line.
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --profile=other -v")
|
2019-09-12 14:13:40 +00:00
|
|
|
.with_stderr_unordered(
|
|
|
|
"\
|
2019-09-12 13:27:15 +00:00
|
|
|
[COMPILING] xxx [..]
|
|
|
|
[COMPILING] yyy [..]
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[RUNNING] `rustc --crate-name xxx [..] -C codegen-units=5 [..]`
|
|
|
|
[RUNNING] `rustc --crate-name yyy [..] -C codegen-units=6 [..]`
|
|
|
|
[RUNNING] `rustc --crate-name foo [..] -C codegen-units=2 [..]`
|
|
|
|
[FINISHED] other [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2019-09-12 17:25:12 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn conflicting_usage() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
|
|
|
"#,
|
2019-09-12 17:25:12 +00:00
|
|
|
)
|
2021-09-24 17:59:00 +00:00
|
|
|
.file("src/main.rs", "fn main() {}")
|
2019-09-12 17:25:12 +00:00
|
|
|
.build();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --profile=dev --release")
|
2019-09-12 17:25:12 +00:00
|
|
|
.with_status(101)
|
2021-07-13 18:59:15 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: conflicting usage of --profile=dev and --release
|
|
|
|
The `--release` flag is the same as `--profile=release`.
|
|
|
|
Remove one flag or the other to continue.
|
|
|
|
",
|
|
|
|
)
|
2019-09-12 17:25:12 +00:00
|
|
|
.run();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("install --profile=release --debug")
|
2019-09-12 17:25:12 +00:00
|
|
|
.with_status(101)
|
2021-07-13 18:59:15 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: conflicting usage of --profile=release and --debug
|
|
|
|
The `--debug` flag is the same as `--profile=dev`.
|
|
|
|
Remove one flag or the other to continue.
|
2021-09-24 17:59:00 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("rustc --profile=dev --release")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
warning: the `--release` flag should not be specified with the `--profile` flag
|
|
|
|
The `--release` flag will be ignored.
|
|
|
|
This was historically accepted, but will become an error in a future release.
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[FINISHED] dev [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("check --profile=dev --release")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: conflicting usage of --profile=dev and --release
|
|
|
|
The `--release` flag is the same as `--profile=release`.
|
|
|
|
Remove one flag or the other to continue.
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("check --profile=test --release")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
warning: the `--release` flag should not be specified with the `--profile` flag
|
|
|
|
The `--release` flag will be ignored.
|
|
|
|
This was historically accepted, but will become an error in a future release.
|
|
|
|
[CHECKING] foo [..]
|
|
|
|
[FINISHED] test [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
// This is OK since the two are the same.
|
|
|
|
p.cargo("rustc --profile=release --release")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo [..]
|
|
|
|
[FINISHED] release [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("build --profile=release --release")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[FINISHED] release [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("install --path . --profile=dev --debug")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[INSTALLING] foo [..]
|
|
|
|
[FINISHED] dev [..]
|
|
|
|
[INSTALLING] [..]
|
|
|
|
[INSTALLED] [..]
|
|
|
|
[WARNING] be sure to add [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("install --path . --profile=release --debug")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
error: conflicting usage of --profile=release and --debug
|
|
|
|
The `--debug` flag is the same as `--profile=dev`.
|
|
|
|
Remove one flag or the other to continue.
|
2021-07-13 18:59:15 +00:00
|
|
|
",
|
|
|
|
)
|
2019-09-12 17:25:12 +00:00
|
|
|
.run();
|
|
|
|
}
|
2019-09-12 17:40:03 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn clean_custom_dirname() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
authors = []
|
2019-09-12 17:40:03 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[profile.other]
|
|
|
|
inherits = "release"
|
|
|
|
"#,
|
2019-09-12 17:40:03 +00:00
|
|
|
)
|
|
|
|
.file("src/main.rs", "fn main() {}")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("build --release")
|
2019-09-21 06:32:07 +00:00
|
|
|
.with_stdout("")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
2019-09-12 17:40:03 +00:00
|
|
|
.run();
|
|
|
|
|
2022-07-15 00:55:44 +00:00
|
|
|
p.cargo("clean -p foo").run();
|
2019-09-12 17:40:03 +00:00
|
|
|
|
|
|
|
p.cargo("build --release")
|
|
|
|
.with_stdout("")
|
2019-09-21 06:32:07 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
2019-09-12 17:40:03 +00:00
|
|
|
.run();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("clean -p foo --release").run();
|
2019-09-12 17:40:03 +00:00
|
|
|
|
|
|
|
p.cargo("build --release")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[FINISHED] release [optimized] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2019-09-21 06:32:07 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_stdout("")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
2019-09-12 17:40:03 +00:00
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --profile=other")
|
2019-09-12 17:40:03 +00:00
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.0.1 ([..])
|
|
|
|
[FINISHED] other [optimized] target(s) in [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("clean").arg("--release").run();
|
2019-09-12 17:40:03 +00:00
|
|
|
|
|
|
|
// Make sure that 'other' was not cleaned
|
|
|
|
assert!(p.build_dir().is_dir());
|
|
|
|
assert!(p.build_dir().join("debug").is_dir());
|
|
|
|
assert!(p.build_dir().join("other").is_dir());
|
|
|
|
assert!(!p.build_dir().join("release").is_dir());
|
|
|
|
|
|
|
|
// This should clean 'other'
|
2023-09-07 03:42:35 +00:00
|
|
|
p.cargo("clean --profile=other")
|
2023-09-10 19:02:17 +00:00
|
|
|
.with_stderr("[REMOVED] [..] files, [..] total")
|
2023-09-07 03:42:35 +00:00
|
|
|
.run();
|
2019-09-12 17:40:03 +00:00
|
|
|
assert!(p.build_dir().join("debug").is_dir());
|
|
|
|
assert!(!p.build_dir().join("other").is_dir());
|
|
|
|
}
|
2019-12-27 03:59:19 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn unknown_profile() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --profile alpha")
|
2019-12-27 03:59:19 +00:00
|
|
|
.with_stderr("[ERROR] profile `alpha` is not defined")
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
// Clean has a separate code path, need to check it too.
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("clean --profile alpha")
|
2019-12-27 03:59:19 +00:00
|
|
|
.with_stderr("[ERROR] profile `alpha` is not defined")
|
|
|
|
.with_status(101)
|
|
|
|
.run();
|
|
|
|
}
|
2021-07-13 18:59:15 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn reserved_profile_names() {
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.doc]
|
|
|
|
opt-level = 1
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo("build --profile=doc")
|
2021-07-13 22:22:09 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr("error: profile `doc` is reserved and not allowed to be explicitly specified")
|
|
|
|
.run();
|
2021-07-13 18:59:15 +00:00
|
|
|
// Not an exhaustive list, just a sample.
|
2021-07-13 22:22:09 +00:00
|
|
|
for name in ["build", "cargo", "check", "rustc", "CaRgO_startswith"] {
|
2021-09-24 04:55:42 +00:00
|
|
|
p.cargo(&format!("build --profile={}", name))
|
2021-07-13 18:59:15 +00:00
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
|
|
|
error: profile name `{}` is reserved
|
|
|
|
Please choose a different name.
|
|
|
|
See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configuring profiles.
|
|
|
|
",
|
|
|
|
name
|
|
|
|
))
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
for name in ["build", "check", "cargo", "rustc", "CaRgO_startswith"] {
|
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
&format!(
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.{}]
|
|
|
|
opt-level = 1
|
|
|
|
"#,
|
|
|
|
name
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
2023-12-12 21:55:09 +00:00
|
|
|
let highlight = "^".repeat(name.len());
|
2021-07-13 18:59:15 +00:00
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(&format!(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] profile name `{name}` is reserved
|
|
|
|
Please choose a different name.
|
|
|
|
See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configuring profiles.
|
|
|
|
--> Cargo.toml:6:30
|
|
|
|
|
|
|
|
|
6 | [profile.{name}]
|
|
|
|
| {highlight}
|
|
|
|
|
|
|
|
|
"
|
2021-07-13 18:59:15 +00:00
|
|
|
))
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
p.change_file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
authors = []
|
|
|
|
|
|
|
|
[profile.debug]
|
|
|
|
debug = 1
|
|
|
|
inherits = "dev"
|
|
|
|
"#,
|
|
|
|
);
|
|
|
|
|
|
|
|
p.cargo("build")
|
|
|
|
.with_status(101)
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
2023-12-14 22:28:05 +00:00
|
|
|
[ERROR] profile name `debug` is reserved
|
|
|
|
To configure the default development profile, use the name `dev` as in [profile.dev]
|
|
|
|
See https://doc.rust-lang.org/cargo/reference/profiles.html for more on configuring profiles.
|
|
|
|
--> Cargo.toml:7:25
|
|
|
|
|
|
|
|
|
7 | [profile.debug]
|
|
|
|
| ^^^^^
|
|
|
|
|
|
2021-07-13 18:59:15 +00:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2021-07-13 22:22:09 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn legacy_commands_support_custom() {
|
|
|
|
// These commands have had `--profile` before custom named profiles.
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.super-dev]
|
|
|
|
codegen-units = 3
|
|
|
|
inherits = "dev"
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
for command in ["rustc", "fix", "check"] {
|
|
|
|
let mut pb = p.cargo(command);
|
|
|
|
if command == "fix" {
|
|
|
|
pb.arg("--allow-no-vcs");
|
|
|
|
}
|
|
|
|
pb.arg("--profile=super-dev")
|
|
|
|
.arg("-v")
|
|
|
|
.with_stderr_contains("[RUNNING] [..]codegen-units=3[..]")
|
|
|
|
.run();
|
|
|
|
p.build_dir().rm_rf();
|
|
|
|
}
|
|
|
|
}
|
2021-09-10 16:40:37 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn legacy_rustc() {
|
|
|
|
// `cargo rustc` historically has supported dev/test/bench/check
|
|
|
|
// other profiles are covered in check::rustc_check
|
|
|
|
let p = project()
|
|
|
|
.file(
|
|
|
|
"Cargo.toml",
|
|
|
|
r#"
|
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.1.0"
|
|
|
|
|
|
|
|
[profile.dev]
|
|
|
|
codegen-units = 3
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
p.cargo("rustc --profile dev -v")
|
|
|
|
.with_stderr(
|
|
|
|
"\
|
|
|
|
[COMPILING] foo v0.1.0 [..]
|
|
|
|
[RUNNING] `rustc --crate-name foo [..]-C codegen-units=3[..]
|
|
|
|
[FINISHED] [..]
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|