// It's easier to read tabs in outputs if they don't show up as literal
// hidden characters
let actual = actual.replace('\t', "<tab>");
- // Let's not deal with \r\n vs \n on windows...
- let actual = actual.replace('\r', "");
- normalize_common(&actual, cwd)
+ if cfg!(windows) {
+ // Let's not deal with \r\n vs \n on windows...
+ let actual = actual.replace('\r', "");
+ normalize_windows(&actual, cwd)
+ } else {
+ actual
+ }
}
/// Normalizes the expected string so that it can be compared against the actual output.
fn normalize_expected(expected: &str, cwd: Option<&Path>) -> String {
let expected = substitute_macros(expected);
- normalize_common(&expected, cwd)
+ if cfg!(windows) {
+ normalize_windows(&expected, cwd)
+ } else {
+ let expected = match cwd {
+ None => expected,
+ Some(cwd) => expected.replace("[CWD]", &cwd.display().to_string()),
+ };
+ let expected = expected.replace("[ROOT]", &paths::root().display().to_string());
+ expected
+ }
}
-/// Normalizes text for both actual and expected strings.
-fn normalize_common(text: &str, cwd: Option<&Path>) -> String {
+/// Normalizes text for both actual and expected strings on Windows.
+fn normalize_windows(text: &str, cwd: Option<&Path>) -> String {
// Let's not deal with / vs \ (windows...)
let text = text.replace('\\', "/");
.with_stderr(
"\
[ERROR] error in [..]/foo/.cargo/config: \
-could not load config key `target.\"cfg(not(target_os = /\"none/\"))\".runner`
+could not load config key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
Caused by:
error in [..]/foo/.cargo/config: \
- could not load config key `target.\"cfg(not(target_os = /\"none/\"))\".runner`
+ could not load config key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
Caused by:
- invalid configuration for key `target.\"cfg(not(target_os = /\"none/\"))\".runner`
+ invalid configuration for key `target.\"cfg(not(target_os = \\\"none\\\"))\".runner`
expected a string or array of strings, but found a boolean for \
- `target.\"cfg(not(target_os = /\"none/\"))\".runner` in [..]/foo/.cargo/config
+ `target.\"cfg(not(target_os = \\\"none\\\"))\".runner` in [..]/foo/.cargo/config
",
)
.run();
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
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
",
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\"
",
)
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\"
",
)