-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: migrate profile* to snapbox #14128
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f58bb77
test: migrate profile_config to snapbox
eth3lbert dbb67df
test: migrate profile_custom to snapbox
eth3lbert 41930ab
test: migrate profile_overrides to snapbox
eth3lbert 02542ef
test: migrate profile_targets to snapbox
eth3lbert 1ba4291
test: migrate profile_trim_paths to snapbox
eth3lbert 1559840
test: migrate profiles to snapbox
eth3lbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
//! Tests for profiles defined in config files. | ||
|
||
#![allow(deprecated)] | ||
|
||
use cargo_test_support::paths::CargoPathExt; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::registry::Package; | ||
use cargo_test_support::{basic_lib_manifest, paths, project}; | ||
use cargo_test_support::{basic_lib_manifest, paths, project, str}; | ||
use cargo_util_schemas::manifest::TomlDebugInfo; | ||
|
||
// TODO: this should be remove once -Zprofile-rustflags is stabilized | ||
|
@@ -33,18 +32,23 @@ fn rustflags_works_with_zflag() { | |
p.cargo("check -v") | ||
.masquerade_as_nightly_cargo(&["profile-rustflags"]) | ||
.with_status(101) | ||
.with_stderr_contains("[..]feature `profile-rustflags` is required[..]") | ||
.with_stderr_data(str![[r#" | ||
[ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`) | ||
|
||
Caused by: | ||
feature `profile-rustflags` is required | ||
... | ||
"#]]) | ||
.run(); | ||
|
||
p.cargo("check -v -Zprofile-rustflags") | ||
.masquerade_as_nightly_cargo(&["profile-rustflags"]) | ||
.with_stderr( | ||
"\ | ||
[CHECKING] foo [..] | ||
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..] | ||
[FINISHED] [..] | ||
", | ||
) | ||
.with_stderr_data(str![[r#" | ||
[CHECKING] foo v0.0.1 ([ROOT]/foo) | ||
[RUNNING] `rustc --crate-name foo [..] -C link-dead-code=yes [..]` | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
|
||
p.change_file( | ||
|
@@ -60,12 +64,11 @@ fn rustflags_works_with_zflag() { | |
|
||
p.cargo("check -v") | ||
.masquerade_as_nightly_cargo(&["profile-rustflags"]) | ||
.with_stderr( | ||
"\ | ||
[FRESH] foo [..] | ||
[FINISHED] [..] | ||
", | ||
) | ||
.with_stderr_data(str![[r#" | ||
[FRESH] foo v0.0.1 ([ROOT]/foo) | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -95,17 +98,14 @@ fn profile_config_validate_warnings() { | |
) | ||
.build(); | ||
|
||
p.cargo("build") | ||
.with_stderr_unordered( | ||
"\ | ||
[WARNING] unused config key `profile.dev.bad-key` in `[..].cargo/config.toml` | ||
[WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[..].cargo/config.toml` | ||
[WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[..].cargo/config.toml` | ||
[COMPILING] foo [..] | ||
[FINISHED] [..] | ||
", | ||
) | ||
.run(); | ||
p.cargo("build").with_stderr_data(str![[r#" | ||
[WARNING] unused config key `profile.dev.bad-key` in `[ROOT]/foo/.cargo/config.toml` | ||
[WARNING] unused config key `profile.dev.build-override.bad-key-bo` in `[ROOT]/foo/.cargo/config.toml` | ||
[WARNING] unused config key `profile.dev.package.bar.bad-key-bar` in `[ROOT]/foo/.cargo/config.toml` | ||
[COMPILING] foo v0.5.0 ([ROOT]/foo) | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]].unordered()).run(); | ||
} | ||
|
||
#[cargo_test] | ||
|
@@ -132,14 +132,13 @@ fn profile_config_error_paths() { | |
|
||
p.cargo("build") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[ERROR] error in [..]/foo/.cargo/config.toml: could not load config key `profile.dev` | ||
.with_stderr_data(str![[r#" | ||
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev` | ||
|
||
Caused by: | ||
error in [..]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string | ||
", | ||
) | ||
error in [ROOT]/home/.cargo/config.toml: `profile.dev.rpath` expected true/false, but found a string | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -159,14 +158,13 @@ fn profile_config_validate_errors() { | |
|
||
p.cargo("build") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[ERROR] config profile `dev` is not valid (defined in `[..]/foo/.cargo/config.toml`) | ||
.with_stderr_data(str![[r#" | ||
[ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`) | ||
|
||
Caused by: | ||
`panic` may not be specified in a `package` profile | ||
", | ||
) | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -186,14 +184,13 @@ fn profile_config_syntax_errors() { | |
|
||
p.cargo("build") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
[ERROR] error in [..]/.cargo/config.toml: could not load config key `profile.dev` | ||
.with_stderr_data(str![[r#" | ||
[ERROR] error in [ROOT]/foo/.cargo/config.toml: could not load config key `profile.dev` | ||
|
||
Caused by: | ||
error in [..]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string | ||
", | ||
) | ||
error in [ROOT]/foo/.cargo/config.toml: `profile.dev.codegen-units` expected an integer, but found a string | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -231,12 +228,12 @@ fn profile_config_override_spec_multiple() { | |
// much of a problem. | ||
p.cargo("build -v") | ||
.with_status(101) | ||
.with_stderr( | ||
"\ | ||
.with_stderr_data(str![[r#" | ||
[LOCKING] 2 packages to latest compatible versions | ||
[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([..])` | ||
found package specs: bar, bar@0.5.0", | ||
) | ||
[ERROR] multiple package overrides in profile `dev` match package `bar v0.5.0 ([ROOT]/foo/bar)` | ||
found package specs: bar, bar@0.5.0 | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -264,22 +261,12 @@ fn profile_config_all_options() { | |
|
||
p.cargo("build --release -v") | ||
.env_remove("CARGO_INCREMENTAL") | ||
.with_stderr( | ||
"\ | ||
[COMPILING] foo [..] | ||
[RUNNING] `rustc --crate-name foo [..] \ | ||
-C opt-level=1 \ | ||
-C panic=abort \ | ||
-C lto[..]\ | ||
-C codegen-units=2 \ | ||
-C debuginfo=2 [..]\ | ||
-C debug-assertions=on \ | ||
-C overflow-checks=off [..]\ | ||
-C rpath [..]\ | ||
-C incremental=[..] | ||
[FINISHED] `release` profile [optimized + debuginfo] [..] | ||
", | ||
) | ||
.with_stderr_data(str![[r#" | ||
[COMPILING] foo v0.0.1 ([ROOT]/foo) | ||
[RUNNING] `rustc --crate-name foo [..] -C opt-level=1 -C panic=abort -C lto[..]-C codegen-units=2 -C debuginfo=2 [..]-C debug-assertions=on -C overflow-checks=off [..]-C rpath --out-dir [ROOT]/foo/target/release/deps -C incremental=[ROOT]/foo/target/release/incremental[..]` | ||
[FINISHED] `release` profile [optimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -318,18 +305,19 @@ fn profile_config_override_precedence() { | |
.build(); | ||
|
||
p.cargo("build -v") | ||
.with_stderr( | ||
"\ | ||
.with_stderr_data(str![[r#" | ||
[LOCKING] 2 packages to latest compatible versions | ||
[COMPILING] bar [..] | ||
[RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..] | ||
[COMPILING] foo [..] | ||
[RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..] | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]", | ||
) | ||
[COMPILING] bar v0.5.0 ([ROOT]/foo/bar) | ||
[RUNNING] `rustc --crate-name bar [..] -C opt-level=2[..]-C codegen-units=2 [..]` | ||
[COMPILING] foo v0.0.1 ([ROOT]/foo) | ||
[RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..]` | ||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
#[allow(deprecated)] | ||
#[cargo_test] | ||
fn profile_config_no_warn_unknown_override() { | ||
let p = project() | ||
|
@@ -371,7 +359,12 @@ fn profile_config_mixed_types() { | |
.build(); | ||
|
||
p.cargo("build -v") | ||
.with_stderr_contains("[..]-C opt-level=3 [..]") | ||
.with_stderr_data(str![[r#" | ||
[COMPILING] foo v0.5.0 ([ROOT]/foo) | ||
[RUNNING] `rustc [..]-C opt-level=3 [..]` | ||
[FINISHED] `dev` profile [optimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
|
@@ -486,10 +479,16 @@ fn named_env_profile() { | |
p.cargo("build -v --profile=other") | ||
.env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1") | ||
.env("CARGO_PROFILE_OTHER_INHERITS", "dev") | ||
.with_stderr_contains("[..]-C codegen-units=1 [..]") | ||
.with_stderr_data(str![[r#" | ||
[COMPILING] foo v0.1.0 ([ROOT]/foo) | ||
[RUNNING] `rustc [..]-C codegen-units=1 [..]` | ||
[FINISHED] `other` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s | ||
|
||
"#]]) | ||
.run(); | ||
} | ||
|
||
#[allow(deprecated)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
#[cargo_test] | ||
fn test_with_dev_profile() { | ||
// The `test` profile inherits from `dev` for both local crates and | ||
|
@@ -512,20 +511,19 @@ fn test_with_dev_profile() { | |
.build(); | ||
p.cargo("test --lib --no-run -v") | ||
.env("CARGO_PROFILE_DEV_DEBUG", "0") | ||
.with_stderr( | ||
"\ | ||
[UPDATING] [..] | ||
.with_stderr_data(str![[r#" | ||
[UPDATING] `dummy-registry` index | ||
[LOCKING] 2 packages to latest compatible versions | ||
[DOWNLOADING] [..] | ||
[DOWNLOADED] [..] | ||
[DOWNLOADING] crates ... | ||
[DOWNLOADED] somedep v1.0.0 (registry `dummy-registry`) | ||
[COMPILING] somedep v1.0.0 | ||
[RUNNING] `rustc --crate-name somedep [..] | ||
[COMPILING] foo v0.1.0 [..] | ||
[RUNNING] `rustc --crate-name foo [..] | ||
[FINISHED] [..] | ||
[EXECUTABLE] `[..]/target/debug/deps/foo-[..][EXE]` | ||
", | ||
) | ||
[RUNNING] `rustc --crate-name somedep [..]` | ||
[COMPILING] foo v0.1.0 ([ROOT]/foo) | ||
[RUNNING] `rustc --crate-name foo [..]` | ||
[FINISHED] `test` profile [unoptimized] target(s) in [ELAPSED]s | ||
[EXECUTABLE] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]` | ||
|
||
"#]]) | ||
.with_stdout_does_not_contain("[..] -C debuginfo=0[..]") | ||
.run(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with_stderr_does_not_contain
is being used in this function.