Skip to content

Commit 950aa4e

Browse files
committed
test: remove duplicate assertion functions
1 parent 4e59631 commit 950aa4e

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

tests/testsuite/config.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cargo::util::context::{
66
};
77
use cargo::CargoResult;
88
use cargo_test_support::compare;
9-
use cargo_test_support::{panic_error, paths, project, symlink_supported, t};
9+
use cargo_test_support::{paths, project, symlink_supported, t};
1010
use cargo_util_schemas::manifest::TomlTrimPaths;
1111
use cargo_util_schemas::manifest::TomlTrimPathsValue;
1212
use cargo_util_schemas::manifest::{self as cargo_toml, TomlDebugInfo, VecStringOrBool as VSOB};
@@ -222,14 +222,7 @@ pub fn assert_error<E: Borrow<anyhow::Error>>(error: E, msgs: &str) {
222222
})
223223
.collect::<Vec<_>>()
224224
.join("\n\n");
225-
assert_match(msgs, &causes);
226-
}
227-
228-
#[track_caller]
229-
pub fn assert_match(expected: &str, actual: &str) {
230-
if let Err(e) = compare::match_exact(expected, actual, "output", "", None) {
231-
panic_error("", e);
232-
}
225+
compare::assert_match_exact(msgs, &causes);
233226
}
234227

235228
#[cargo_test]
@@ -297,7 +290,7 @@ f1 = 1
297290
let expected = "\
298291
[WARNING] `[ROOT]/.cargo/config` is deprecated in favor of `config.toml`
299292
[NOTE] if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`";
300-
assert_match(expected, &output);
293+
compare::assert_match_exact(expected, &output);
301294
}
302295

303296
#[cargo_test]
@@ -323,7 +316,7 @@ f1 = 1
323316

324317
// It should NOT have warned for the symlink.
325318
let output = read_output(gctx);
326-
assert_match("", &output);
319+
compare::assert_match_exact("", &output);
327320
}
328321

329322
#[cargo_test]
@@ -349,7 +342,7 @@ f1 = 1
349342

350343
// It should NOT have warned for the symlink.
351344
let output = read_output(gctx);
352-
assert_match("", &output);
345+
compare::assert_match_exact("", &output);
353346
}
354347

355348
#[cargo_test]
@@ -375,7 +368,7 @@ f1 = 1
375368

376369
// It should NOT have warned for this situation.
377370
let output = read_output(gctx);
378-
assert_match("", &output);
371+
compare::assert_match_exact("", &output);
379372
}
380373

381374
#[cargo_test]
@@ -405,7 +398,7 @@ f1 = 2
405398
let expected = "\
406399
[WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
407400
";
408-
assert_match(expected, &output);
401+
compare::assert_match_exact(expected, &output);
409402
}
410403

411404
#[cargo_test]
@@ -439,7 +432,7 @@ unused = 456
439432
let expected = "\
440433
warning: unused config key `S.unused` in `[..]/.cargo/config.toml`
441434
";
442-
assert_match(expected, &output);
435+
compare::assert_match_exact(expected, &output);
443436
}
444437

445438
#[cargo_test]

tests/testsuite/config_cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Tests for the --config CLI option.
22
33
use super::config::{
4-
assert_error, assert_match, read_output, write_config_at, write_config_toml,
5-
GlobalContextBuilder,
4+
assert_error, read_output, write_config_at, write_config_toml, GlobalContextBuilder,
65
};
76
use cargo::util::context::Definition;
7+
use cargo_test_support::compare;
88
use cargo_test_support::paths;
99
use std::{collections::HashMap, fs};
1010

@@ -344,7 +344,7 @@ fn unused_key() {
344344
let expected = "\
345345
warning: unused config key `build.unused` in `--config cli option`
346346
";
347-
assert_match(expected, &output);
347+
compare::assert_match_exact(expected, &output);
348348
}
349349

350350
#[cargo_test]

0 commit comments

Comments
 (0)