diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index eb4dea9f1ba..0cf807b15e8 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -1,9 +1,8 @@ //! Tests for `[alias]` config command aliases. -#![allow(deprecated)] - use std::env; +use cargo_test_support::str; use cargo_test_support::tools::echo_subcommand; use cargo_test_support::{basic_bin_manifest, project}; @@ -23,11 +22,11 @@ fn alias_incorrect_config_type() { p.cargo("b-cargo-test -v") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] invalid configuration for key `alias.b-cargo-test` -expected a list, but found a integer for [..]", - ) +expected a list, but found a integer for `alias.b-cargo-test` in [ROOT]/foo/.cargo/config.toml + +"#]]) .run(); } @@ -47,22 +46,21 @@ fn alias_malformed_config_string() { p.cargo("b-cargo-test -v") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] could not load Cargo configuration Caused by: - could not parse TOML configuration in `[..]/config.toml` + could not parse TOML configuration in `[ROOT]/foo/.cargo/config.toml` Caused by: - TOML parse error at line [..] + TOML parse error at line 3, column 32 | 3 | b-cargo-test = ` | ^ invalid string - expected `\"`, `'` -", - ) + expected `"`, `'` + +"#]]) .run(); } @@ -82,23 +80,22 @@ fn alias_malformed_config_list() { p.cargo("b-cargo-test -v") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] could not load Cargo configuration Caused by: - failed to load TOML configuration from `[..]/config.toml` + failed to load TOML configuration from `[ROOT]/foo/.cargo/config.toml` Caused by: - [..] `alias` + failed to parse key `alias` Caused by: - [..] `b-cargo-test` + failed to parse key `b-cargo-test` Caused by: expected string but found integer in list -", - ) + +"#]]) .run(); } @@ -117,11 +114,12 @@ fn alias_config() { .build(); p.cargo("b-cargo-test -v") - .with_stderr_contains( - "\ -[COMPILING] foo v0.5.0 [..] -[RUNNING] `rustc --crate-name foo [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -141,11 +139,12 @@ fn dependent_alias() { .build(); p.cargo("a-cargo-test") - .with_stderr_contains( - "\ -[COMPILING] foo v0.5.0 [..] -[RUNNING] `rustc --crate-name foo [..]", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -163,13 +162,12 @@ fn builtin_alias_shadowing_external_subcommand() { p.cargo("t") .env("PATH", &path) - .with_stderr( - "\ -[COMPILING] foo v0.5.0 [..] -[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [..] -[RUNNING] unittests src/main.rs [..] -", - ) + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s +[RUNNING] unittests src/main.rs (target/debug/deps/foo-[HASH][EXE]) + +"#]]) .run(); } @@ -194,14 +192,14 @@ fn alias_shadowing_external_subcommand() { p.cargo("echo") .env("PATH", &path) - .with_stderr("\ + .with_stderr_data(str![[r#" [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` This was previously accepted but is being phased out; it will become a hard error in a future release. For more information, see issue #10049 . -[COMPILING] foo v0.5.0 [..] -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -229,36 +227,35 @@ fn default_args_alias() { p.cargo("echo") .env("PATH", &path) .with_status(101) - .with_stderr("\ + .with_stderr_data(str![[r#" [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` This was previously accepted but is being phased out; it will become a hard error in a future release. For more information, see issue #10049 . -error: alias echo has unresolvable recursive definition: echo -> echo -", - ) +[ERROR] alias echo has unresolvable recursive definition: echo -> echo + +"#]]) .run(); p.cargo("test-1") .env("PATH", &path) .with_status(101) - .with_stderr("\ + .with_stderr_data(str![[r#" [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` This was previously accepted but is being phased out; it will become a hard error in a future release. For more information, see issue #10049 . -error: alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo -", - ) +[ERROR] alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo + +"#]]) .run(); // Builtins are not expanded by rule p.cargo("build") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] user-defined alias `build` is ignored, because it is shadowed by a built-in command -[COMPILING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -280,16 +277,18 @@ fn corecursive_alias() { p.cargo("test-1") .with_status(101) - .with_stderr( - "error: alias test-1 has unresolvable recursive definition: test-1 -> test-2 -> test-3 -> test-1", - ) + .with_stderr_data(str![[r#" +[ERROR] alias test-1 has unresolvable recursive definition: test-1 -> test-2 -> test-3 -> test-1 + +"#]]) .run(); p.cargo("test-2") .with_status(101) - .with_stderr( - "error: alias test-2 has unresolvable recursive definition: test-2 -> test-3 -> test-1 -> test-2", - ) + .with_stderr_data(str![[r#" +[ERROR] alias test-2 has unresolvable recursive definition: test-2 -> test-3 -> test-1 -> test-2 + +"#]]) .run(); } @@ -308,8 +307,12 @@ fn alias_list_test() { .build(); p.cargo("b-cargo-test -v") - .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") - .with_stderr_contains("[RUNNING] `rustc --crate-name [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -328,8 +331,12 @@ fn alias_with_flags_config() { .build(); p.cargo("b-cargo-test -v") - .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") - .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..]") + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo [..] +[FINISHED] `release` profile [optimized] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -348,13 +355,12 @@ fn alias_cannot_shadow_builtin_command() { .build(); p.cargo("build") - .with_stderr( - "\ + .with_stderr_data(str![[r#" [WARNING] user-defined alias `build` is ignored, because it is shadowed by a built-in command -[COMPILING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] -", - ) +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -373,13 +379,12 @@ fn alias_override_builtin_alias() { .build(); p.cargo("b") - .with_stderr( - "\ -[COMPILING] foo v0.5.0 ([..]) -[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..] + .with_stderr_data(str![[r#" +[COMPILING] foo v0.5.0 ([ROOT]/foo) +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [RUNNING] `target/debug/foo[EXE]` -", - ) + +"#]]) .run(); } @@ -394,7 +399,12 @@ fn builtin_alias_takes_options() { ) .build(); - p.cargo("r --example ex1 -- asdf").with_stdout("asdf").run(); + p.cargo("r --example ex1 -- asdf") + .with_stdout_data(str![[r#" +asdf + +"#]]) + .run(); } #[cargo_test] @@ -403,13 +413,12 @@ fn global_options_with_alias() { let p = project().file("src/lib.rs", "").build(); p.cargo("-v c") - .with_stderr( - "\ -[CHECKING] foo [..] -[RUNNING] `rustc [..] -[FINISHED] `dev` profile [..] -", - ) + .with_stderr_data(str![[r#" +[CHECKING] foo v0.0.1 ([ROOT]/foo) +[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] +[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s + +"#]]) .run(); } @@ -422,13 +431,12 @@ fn weird_check() { p.cargo("-- check --invalid_argument -some-other-argument") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] trailing arguments after built-in command `check` are unsupported: `--invalid_argument -some-other-argument` To pass the arguments to the subcommand, remove `--` -", - ) + +"#]]) .run(); } @@ -449,20 +457,18 @@ fn empty_alias() { p.cargo("string") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] subcommand is required, but `alias.string` is empty -", - ) + +"#]]) .run(); p.cargo("array") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] subcommand is required, but `alias.array` is empty -", - ) + +"#]]) .run(); } @@ -482,10 +488,9 @@ fn alias_no_subcommand() { p.cargo("a") .with_status(101) - .with_stderr( - "\ + .with_stderr_data(str![[r#" [ERROR] subcommand is required, add a subcommand to the command alias `alias.a` -", - ) + +"#]]) .run(); } diff --git a/tests/testsuite/cargo_config/mod.rs b/tests/testsuite/cargo_config/mod.rs index 039d11f91ca..59297d228a6 100644 --- a/tests/testsuite/cargo_config/mod.rs +++ b/tests/testsuite/cargo_config/mod.rs @@ -1,9 +1,9 @@ //! Tests for the `cargo config` command. -#![allow(deprecated)] - use super::config::write_config_at; use cargo_test_support::paths; +use cargo_test_support::prelude::*; +use cargo_test_support::str; use std::fs; use std::path::PathBuf; @@ -26,10 +26,11 @@ fn gated() { cargo_process("config get") .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stderr("\ -error: the `cargo config` command is unstable, pass `-Z unstable-options` to enable it + .with_stderr_data(str![[r#" +[ERROR] the `cargo config` command is unstable, pass `-Z unstable-options` to enable it See https://github.com/rust-lang/cargo/issues/9301 for more information about the `cargo config` command. -") + +"#]]) .run(); } @@ -81,23 +82,22 @@ fn get_toml() { .env("CARGO_ALIAS_BAR", "cat dog") .env("CARGO_BUILD_JOBS", "100") // The weird forward slash in the linux line is due to testsuite normalization. - .with_stdout( - "\ -alias.foo = \"abc --xyz\" -alias.sub-example = [\"sub\", \"example\"] + .with_stdout_data(str![[r#" +alias.foo = "abc --xyz" +alias.sub-example = ["sub", "example"] build.jobs = 99 -build.rustflags = [\"--flag-global\", \"--flag-directory\"] -extra-table.somekey = \"somevalue\" +build.rustflags = ["--flag-global", "--flag-directory"] +extra-table.somekey = "somevalue" profile.dev.opt-level = 3 profile.dev.package.foo.opt-level = 1 -target.'cfg(target_os = \"linux\")'.runner = \"runme\" +target.'cfg(target_os = "linux")'.runner = "runme" # The following environment variables may affect the loaded values. # CARGO_ALIAS_BAR=[..]cat dog[..] # CARGO_BUILD_JOBS=100 # CARGO_HOME=[ROOT]/home/.cargo -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); // Env keys work if they are specific. @@ -105,37 +105,45 @@ target.'cfg(target_os = \"linux\")'.runner = \"runme\" .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_JOBS", "100") - .with_stdout("build.jobs = 100") - .with_stderr("") + .with_stdout_data(str![[r#" +build.jobs = 100 + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); // Array value. cargo_process("config get build.rustflags -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout("build.rustflags = [\"--flag-global\", \"--flag-directory\"]") - .with_stderr("") + .with_stdout_data(str![[r#" +build.rustflags = ["--flag-global", "--flag-directory"] + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); // Sub-table cargo_process("config get profile -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout( - "\ + .with_stdout_data(str![[r#" profile.dev.opt-level = 3 profile.dev.package.foo.opt-level = 1 -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); // Specific profile entry. cargo_process("config get profile.dev.opt-level -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout("profile.dev.opt-level = 3") - .with_stderr("") + .with_stdout_data(str![[r#" +profile.dev.opt-level = 3 + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); // A key that isn't set. @@ -143,8 +151,11 @@ profile.dev.package.foo.opt-level = 1 .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stdout("") - .with_stderr("error: config value `build.rustc` is not set") + .with_stdout_data(str![[r#""#]]) + .with_stderr_data(str![[r#" +[ERROR] config value `build.rustc` is not set + +"#]]) .run(); // A key that is not part of Cargo's config schema. @@ -152,97 +163,140 @@ profile.dev.package.foo.opt-level = 1 .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stdout("") - .with_stderr("error: config value `not.set` is not set") + .with_stdout_data(str![[r#""#]]) + .with_stderr_data(str![[r#" +[ERROR] config value `not.set` is not set + +"#]]) .run(); } #[cargo_test] fn get_json() { - // Notes: - // - This does not show env vars at all. :( - let all_json = r#" - { - "alias": { - "foo": "abc --xyz", - "sub-example": [ - "sub", - "example" - ] - }, - "build": { - "jobs": 99, - "rustflags": [ - "--flag-global", - "--flag-directory" - ] - }, - "extra-table": { - "somekey": "somevalue" - }, - "profile": { - "dev": { - "opt-level": 3, - "package": { - "foo": { - "opt-level": 1 - } - } - } - }, - "target": { - "cfg(target_os = \"linux\")": { - "runner": "runme" - } - } - } - "#; let sub_folder = common_setup(); cargo_process("config get --format=json -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_ALIAS_BAR", "cat dog") .env("CARGO_BUILD_JOBS", "100") - .with_json(all_json) - .with_stderr( - "\ -note: The following environment variables may affect the loaded values. + .with_stdout_data( + r#" +{ + "alias": { + "foo": "abc --xyz", + "sub-example": [ + "sub", + "example" + ] + }, + "build": { + "jobs": 99, + "rustflags": [ + "--flag-global", + "--flag-directory" + ] + }, + "extra-table": { + "somekey": "somevalue" + }, + "profile": { + "dev": { + "opt-level": 3, + "package": { + "foo": { + "opt-level": 1 + } + } + } + }, + "target": { + "cfg(target_os = \"linux\")": { + "runner": "runme" + } + } +} + +"# + .json(), + ) + .with_stderr_data(str![[r#" +[NOTE] The following environment variables may affect the loaded values. CARGO_ALIAS_BAR=[..]cat dog[..] CARGO_BUILD_JOBS=100 CARGO_HOME=[ROOT]/home/.cargo -", - ) + +"#]]) .run(); // json-value is the same for the entire root table cargo_process("config get --format=json-value -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_json(all_json) - .with_stderr( - "\ -note: The following environment variables may affect the loaded values. -CARGO_HOME=[ROOT]/home/.cargo -", + .with_stdout_data( + r#" +{ + "alias": { + "foo": "abc --xyz", + "sub-example": [ + "sub", + "example" + ] + }, + "build": { + "jobs": 99, + "rustflags": [ + "--flag-global", + "--flag-directory" + ] + }, + "extra-table": { + "somekey": "somevalue" + }, + "profile": { + "dev": { + "opt-level": 3, + "package": { + "foo": { + "opt-level": 1 + } + } + } + }, + "target": { + "cfg(target_os = \"linux\")": { + "runner": "runme" + } + } +} + +"# + .json(), ) + .with_stderr_data(str![[r#" +[NOTE] The following environment variables may affect the loaded values. +CARGO_HOME=[ROOT]/home/.cargo + +"#]]) .run(); cargo_process("config get --format=json build.jobs -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_json( - r#" - {"build": {"jobs": 99}} - "#, - ) - .with_stderr("") + .with_stdout_data(str![[r#" +{"build":{"jobs":99}} + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --format=json-value build.jobs -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout("99") - .with_stderr("") + .with_stdout_data(str![[r#" +99 + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); } @@ -252,44 +306,42 @@ fn show_origin_toml() { cargo_process("config get --show-origin -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stdout( - "\ -alias.foo = \"abc --xyz\" # [ROOT]/home/.cargo/config.toml + .with_stdout_data(str![[r#" +alias.foo = "abc --xyz" # [ROOT]/home/.cargo/config.toml alias.sub-example = [ - \"sub\", # [ROOT]/foo/.cargo/config.toml - \"example\", # [ROOT]/foo/.cargo/config.toml + "sub", # [ROOT]/foo/.cargo/config.toml + "example", # [ROOT]/foo/.cargo/config.toml ] build.jobs = 99 # [ROOT]/home/.cargo/config.toml build.rustflags = [ - \"--flag-global\", # [ROOT]/home/.cargo/config.toml - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml + "--flag-global", # [ROOT]/home/.cargo/config.toml + "--flag-directory", # [ROOT]/foo/.cargo/config.toml ] -extra-table.somekey = \"somevalue\" # [ROOT]/home/.cargo/config.toml +extra-table.somekey = "somevalue" # [ROOT]/home/.cargo/config.toml profile.dev.opt-level = 3 # [ROOT]/home/.cargo/config.toml profile.dev.package.foo.opt-level = 1 # [ROOT]/home/.cargo/config.toml -target.'cfg(target_os = \"linux\")'.runner = \"runme\" # [ROOT]/home/.cargo/config.toml +target.'cfg(target_os = "linux")'.runner = "runme" # [ROOT]/home/.cargo/config.toml # The following environment variables may affect the loaded values. # CARGO_HOME=[ROOT]/home/.cargo -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --show-origin build.rustflags -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_RUSTFLAGS", "env1 env2") - .with_stdout( - "\ + .with_stdout_data(str![[r#" build.rustflags = [ - \"--flag-global\", # [ROOT]/home/.cargo/config.toml - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml - \"env1\", # environment variable `CARGO_BUILD_RUSTFLAGS` - \"env2\", # environment variable `CARGO_BUILD_RUSTFLAGS` + "--flag-global", # [ROOT]/home/.cargo/config.toml + "--flag-directory", # [ROOT]/foo/.cargo/config.toml + "env1", # environment variable `CARGO_BUILD_RUSTFLAGS` + "env2", # environment variable `CARGO_BUILD_RUSTFLAGS` ] -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); } @@ -300,8 +352,11 @@ fn show_origin_toml_cli() { .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_JOBS", "1") - .with_stdout("build.jobs = 123 # --config cli option") - .with_stderr("") + .with_stdout_data(str![[r#" +build.jobs = 123 # --config cli option + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --show-origin build.rustflags -Zunstable-options --config") @@ -309,19 +364,18 @@ fn show_origin_toml_cli() { .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_RUSTFLAGS", "env1 env2") - .with_stdout( - "\ + .with_stdout_data(str![[r#" build.rustflags = [ - \"--flag-global\", # [ROOT]/home/.cargo/config.toml - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml - \"env1\", # environment variable `CARGO_BUILD_RUSTFLAGS` - \"env2\", # environment variable `CARGO_BUILD_RUSTFLAGS` - \"cli1\", # --config cli option - \"cli2\", # --config cli option + "--flag-global", # [ROOT]/home/.cargo/config.toml + "--flag-directory", # [ROOT]/foo/.cargo/config.toml + "env1", # environment variable `CARGO_BUILD_RUSTFLAGS` + "env2", # environment variable `CARGO_BUILD_RUSTFLAGS` + "cli1", # --config cli option + "cli2", # --config cli option ] -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); } @@ -332,7 +386,10 @@ fn show_origin_json() { .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stderr("error: the `json` format does not support --show-origin, try the `toml` format instead") + .with_stderr_data(str![[r#" +[ERROR] the `json` format does not support --show-origin, try the `toml` format instead + +"#]]) .run(); } @@ -344,8 +401,7 @@ fn unmerged_toml() { .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_ALIAS_BAR", "cat dog") .env("CARGO_BUILD_JOBS", "100") - .with_stdout( - "\ + .with_stdout_data(str![[r#" # Environment variables # CARGO=[..] # CARGO_ALIAS_BAR=[..]cat dog[..] @@ -353,58 +409,57 @@ fn unmerged_toml() { # CARGO_HOME=[ROOT]/home/.cargo # [ROOT]/foo/.cargo/config.toml -alias.sub-example = [\"sub\", \"example\"] -build.rustflags = [\"--flag-directory\"] +alias.sub-example = ["sub", "example"] +build.rustflags = ["--flag-directory"] # [ROOT]/home/.cargo/config.toml -alias.foo = \"abc --xyz\" +alias.foo = "abc --xyz" build.jobs = 99 -build.rustflags = [\"--flag-global\"] -extra-table.somekey = \"somevalue\" +build.rustflags = ["--flag-global"] +extra-table.somekey = "somevalue" profile.dev.opt-level = 3 profile.dev.package.foo.opt-level = 1 -target.'cfg(target_os = \"linux\")'.runner = \"runme\" +target.'cfg(target_os = "linux")'.runner = "runme" -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --merged=no build.rustflags -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_RUSTFLAGS", "env1 env2") - .with_stdout( - "\ + .with_stdout_data(str![[r#" # Environment variables # CARGO_BUILD_RUSTFLAGS=[..]env1 env2[..] # [ROOT]/foo/.cargo/config.toml -build.rustflags = [\"--flag-directory\"] +build.rustflags = ["--flag-directory"] # [ROOT]/home/.cargo/config.toml -build.rustflags = [\"--flag-global\"] +build.rustflags = ["--flag-global"] -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --merged=no does.not.exist -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) - .with_stderr("") - .with_stderr("") + .with_stderr_data(str![[r#""#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --merged=no build.rustflags.extra -Zunstable-options") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stderr( - "error: expected table for configuration key `build.rustflags`, \ - but found array in [ROOT]/foo/.cargo/config.toml", - ) + .with_stderr_data(str![[r#" +[ERROR] expected table for configuration key `build.rustflags`, but found array in [ROOT]/foo/.cargo/config.toml + +"#]]) .run(); } @@ -416,23 +471,22 @@ fn unmerged_toml_cli() { .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .env("CARGO_BUILD_RUSTFLAGS", "env1 env2") - .with_stdout( - "\ + .with_stdout_data(str![[r#" # --config cli option -build.rustflags = [\"cli1\", \"cli2\"] +build.rustflags = ["cli1", "cli2"] # Environment variables # CARGO_BUILD_RUSTFLAGS=[..]env1 env2[..] # [ROOT]/foo/.cargo/config.toml -build.rustflags = [\"--flag-directory\"] +build.rustflags = ["--flag-directory"] # [ROOT]/home/.cargo/config.toml -build.rustflags = [\"--flag-global\"] +build.rustflags = ["--flag-global"] -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); } @@ -443,9 +497,10 @@ fn unmerged_json() { .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config"]) .with_status(101) - .with_stderr( - "error: the `json` format does not support --merged=no, try the `toml` format instead", - ) + .with_stderr_data(str![[r#" +[ERROR] the `json` format does not support --merged=no, try the `toml` format instead + +"#]]) .run(); } @@ -473,52 +528,53 @@ fn includes() { cargo_process("config get build.rustflags -Zunstable-options -Zconfig-include") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config", "config-include"]) - .with_stdout(r#"build.rustflags = ["--flag-global", "--flag-other", "--flag-directory"]"#) - .with_stderr("") + .with_stdout_data(str![[r#" +build.rustflags = ["--flag-global", "--flag-other", "--flag-directory"] + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get build.rustflags --show-origin -Zunstable-options -Zconfig-include") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config", "config-include"]) - .with_stdout( - "\ + .with_stdout_data(str![[r#" build.rustflags = [ - \"--flag-global\", # [ROOT]/home/.cargo/config.toml - \"--flag-other\", # [ROOT]/foo/.cargo/other.toml - \"--flag-directory\", # [ROOT]/foo/.cargo/config.toml + "--flag-global", # [ROOT]/home/.cargo/config.toml + "--flag-other", # [ROOT]/foo/.cargo/other.toml + "--flag-directory", # [ROOT]/foo/.cargo/config.toml ] -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); cargo_process("config get --merged=no -Zunstable-options -Zconfig-include") .cwd(&sub_folder.parent().unwrap()) .masquerade_as_nightly_cargo(&["cargo-config", "config-include"]) - .with_stdout( - "\ + .with_stdout_data(str![[r#" # Environment variables # CARGO=[..] # CARGO_HOME=[ROOT]/home/.cargo # [ROOT]/foo/.cargo/other.toml -build.rustflags = [\"--flag-other\"] +build.rustflags = ["--flag-other"] # [ROOT]/foo/.cargo/config.toml -build.rustflags = [\"--flag-directory\"] -include = \"other.toml\" +build.rustflags = ["--flag-directory"] +include = "other.toml" # [ROOT]/home/.cargo/config.toml -alias.foo = \"abc --xyz\" +alias.foo = "abc --xyz" build.jobs = 99 -build.rustflags = [\"--flag-global\"] -extra-table.somekey = \"somevalue\" +build.rustflags = ["--flag-global"] +extra-table.somekey = "somevalue" profile.dev.opt-level = 3 profile.dev.package.foo.opt-level = 1 -target.'cfg(target_os = \"linux\")'.runner = \"runme\" +target.'cfg(target_os = "linux")'.runner = "runme" -", - ) - .with_stderr("") + +"#]]) + .with_stderr_data(str![[r#""#]]) .run(); }