Skip to content

Commit

Permalink
test: switch to assert_match_exact
Browse files Browse the repository at this point in the history
There is no need to provide additional messages here.
  • Loading branch information
weihanglo committed May 7, 2024
1 parent 7ae5a59 commit bfb1a8b
Showing 1 changed file with 14 additions and 46 deletions.
60 changes: 14 additions & 46 deletions tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Tests specific to artifact dependencies, designated using
//! the new `dep = { artifact = "bin", … }` syntax in manifests.

use cargo_test_support::compare::match_exact;
use cargo_test_support::compare;
use cargo_test_support::registry::{Package, RegistryBuilder};
use cargo_test_support::{
basic_bin_manifest, basic_manifest, cross_compile, project, publish, registry, rustc_host,
Expand Down Expand Up @@ -593,35 +593,27 @@ fn build_script_with_bin_artifacts() {
.run();

let build_script_output = build_script_output_string(&p, "foo");
let msg = "we need the binary directory for this artifact along with all binary paths";
// we need the binary directory for this artifact along with all binary paths
if cfg!(target_env = "msvc") {
match_exact(
compare::assert_match_exact(
"[..]/artifact/bar-[..]/bin/baz.exe\n\
[..]/artifact/bar-[..]/staticlib/bar-[..].lib\n\
[..]/artifact/bar-[..]/cdylib/bar.dll\n\
[..]/artifact/bar-[..]/bin\n\
[..]/artifact/bar-[..]/bin/bar.exe\n\
[..]/artifact/bar-[..]/bin/bar.exe",
&build_script_output,
msg,
"",
None,
)
.unwrap();
} else {
match_exact(
compare::assert_match_exact(
"[..]/artifact/bar-[..]/bin/baz-[..]\n\
[..]/artifact/bar-[..]/staticlib/libbar-[..].a\n\
[..]/artifact/bar-[..]/cdylib/[..]bar.[..]\n\
[..]/artifact/bar-[..]/bin\n\
[..]/artifact/bar-[..]/bin/bar-[..]\n\
[..]/artifact/bar-[..]/bin/bar-[..]",
&build_script_output,
msg,
"",
None,
)
.unwrap();
}

assert!(
Expand Down Expand Up @@ -783,31 +775,22 @@ fn build_script_with_selected_dashed_bin_artifact_and_lib_true() {
.run();

let build_script_output = build_script_output_string(&p, "foo");
let msg = "we need the binary directory for this artifact and the binary itself";

// we need the binary directory for this artifact and the binary itself
if cfg!(target_env = "msvc") {
cargo_test_support::compare::match_exact(
compare::assert_match_exact(
&format!(
"[..]/artifact/bar-baz-[..]/bin\n\
[..]/artifact/bar-baz-[..]/bin/baz_suffix{}",
std::env::consts::EXE_SUFFIX,
),
&build_script_output,
msg,
"",
None,
)
.unwrap();
);
} else {
cargo_test_support::compare::match_exact(
compare::assert_match_exact(
"[..]/artifact/bar-baz-[..]/bin\n\
[..]/artifact/bar-baz-[..]/bin/baz_suffix-[..]",
&build_script_output,
msg,
"",
None,
)
.unwrap();
);
}

assert!(
Expand Down Expand Up @@ -1757,14 +1740,7 @@ fn allow_dep_renames_with_multiple_versions() {
.with_stderr_contains("[COMPILING] foo [..]")
.run();
let build_script_output = build_script_output_string(&p, "foo");
match_exact(
"0.5.0\n1.0.0",
&build_script_output,
"build script output",
"",
None,
)
.unwrap();
compare::assert_match_exact("0.5.0\n1.0.0", &build_script_output);
}

#[cargo_test]
Expand Down Expand Up @@ -3240,26 +3216,18 @@ fn build_only_specified_artifact_library() {
.cargo("build -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.run();
match_exact(
compare::assert_match_exact(
"cdylib present: true\nstaticlib present: false",
&build_script_output_string(&cdylib, "foo"),
"build script output",
"",
None,
)
.unwrap();
);

let staticlib = create_project("staticlib");
staticlib
.cargo("build -Z bindeps")
.masquerade_as_nightly_cargo(&["bindeps"])
.run();
match_exact(
compare::assert_match_exact(
"cdylib present: false\nstaticlib present: true",
&build_script_output_string(&staticlib, "foo"),
"build script output",
"",
None,
)
.unwrap();
);
}

0 comments on commit bfb1a8b

Please sign in to comment.