Skip to content

Commit 1fb0652

Browse files
Merge pull request #339 from google:fix-for-nightly
PiperOrigin-RevId: 591267784
2 parents 281b6b8 + 19a9c2a commit 1fb0652

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

googletest/src/matchers/each_matcher.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ mod tests {
238238
result,
239239
err(displays_as(contains_substring(indoc!(
240240
"
241-
Value of: vec![vec! [1, 2], vec! [1]]
242241
Expected: only contains elements that only contains elements that is equal to 1
243242
Actual: [[1, 2], [1]],
244243
whose element #0 is [1, 2], whose element #1 is 2, which isn't equal to 1"

googletest/tests/elements_are_matcher_test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ fn elements_are_produces_correct_failure_message_nested() -> Result<()> {
8282
result,
8383
err(displays_as(contains_substring(indoc!(
8484
"
85-
Value of: vec![vec! [0, 1], vec! [1, 2]]
8685
Expected: has elements:
8786
0. has elements:
8887
0. is equal to 1

googletest/tests/matches_pattern_test.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ fn has_meaningful_assertion_failure_message_when_wrong_enum_variant_is_used() ->
202202
verify_that!(
203203
result,
204204
err(displays_as(contains_substring(indoc! {"
205-
Value of: actual
206-
Expected: is AnEnum :: B which has field `0`, which is equal to 123
207205
Actual: A(123),
208206
which has the wrong enum variant `A`
209207
"
@@ -399,6 +397,12 @@ fn matches_enum_without_field() -> Result<()> {
399397
verify_that!(actual, matches_pattern!(AnEnum::A))
400398
}
401399

400+
#[rustversion::before(1.76)]
401+
const ANENUM_A_REPR: &str = "AnEnum :: A";
402+
403+
#[rustversion::since(1.76)]
404+
const ANENUM_A_REPR: &str = "AnEnum::A";
405+
402406
#[test]
403407
fn generates_correct_failure_output_when_enum_variant_without_field_is_not_matched() -> Result<()> {
404408
#[derive(Debug)]
@@ -411,7 +415,7 @@ fn generates_correct_failure_output_when_enum_variant_without_field_is_not_match
411415

412416
let result = verify_that!(actual, matches_pattern!(AnEnum::A));
413417

414-
verify_that!(result, err(displays_as(contains_substring("is not AnEnum :: A"))))
418+
verify_that!(result, err(displays_as(contains_substring(format!("is not {ANENUM_A_REPR}")))))
415419
}
416420

417421
#[test]
@@ -424,7 +428,7 @@ fn generates_correct_failure_output_when_enum_variant_without_field_is_matched()
424428

425429
let result = verify_that!(actual, not(matches_pattern!(AnEnum::A)));
426430

427-
verify_that!(result, err(displays_as(contains_substring("is AnEnum :: A"))))
431+
verify_that!(result, err(displays_as(contains_substring(format!("is {ANENUM_A_REPR}")))))
428432
}
429433

430434
#[test]
@@ -463,7 +467,9 @@ fn includes_enum_variant_in_description_with_field() -> Result<()> {
463467

464468
verify_that!(
465469
result,
466-
err(displays_as(contains_substring("Expected: is AnEnum :: A which has field `0`")))
470+
err(displays_as(contains_substring(format!(
471+
"Expected: is {ANENUM_A_REPR} which has field `0`"
472+
))))
467473
)
468474
}
469475

@@ -479,9 +485,9 @@ fn includes_enum_variant_in_negative_description_with_field() -> Result<()> {
479485

480486
verify_that!(
481487
result,
482-
err(displays_as(contains_substring(
483-
"Expected: is not AnEnum :: A which has field `0`, which is equal to"
484-
)))
488+
err(displays_as(contains_substring(format!(
489+
"Expected: is not {ANENUM_A_REPR} which has field `0`, which is equal to"
490+
))))
485491
)
486492
}
487493

@@ -497,9 +503,9 @@ fn includes_enum_variant_in_description_with_two_fields() -> Result<()> {
497503

498504
verify_that!(
499505
result,
500-
err(displays_as(contains_substring(
501-
"Expected: is AnEnum :: A which has all the following properties"
502-
)))
506+
err(displays_as(contains_substring(format!(
507+
"Expected: is {ANENUM_A_REPR} which has all the following properties"
508+
))))
503509
)
504510
}
505511

@@ -515,9 +521,9 @@ fn includes_enum_variant_in_description_with_three_fields() -> Result<()> {
515521

516522
verify_that!(
517523
result,
518-
err(displays_as(contains_substring(
519-
"Expected: is AnEnum :: A which has all the following properties"
520-
)))
524+
err(displays_as(contains_substring(format!(
525+
"Expected: is {ANENUM_A_REPR} which has all the following properties"
526+
))))
521527
)
522528
}
523529

@@ -533,7 +539,9 @@ fn includes_enum_variant_in_description_with_named_field() -> Result<()> {
533539

534540
verify_that!(
535541
result,
536-
err(displays_as(contains_substring("Expected: is AnEnum :: A which has field `field`")))
542+
err(displays_as(contains_substring(format!(
543+
"Expected: is {ANENUM_A_REPR} which has field `field`"
544+
))))
537545
)
538546
}
539547

@@ -552,9 +560,9 @@ fn includes_enum_variant_in_description_with_two_named_fields() -> Result<()> {
552560

553561
verify_that!(
554562
result,
555-
err(displays_as(contains_substring(
556-
"Expected: is AnEnum :: A which has all the following properties"
557-
)))
563+
err(displays_as(contains_substring(format!(
564+
"Expected: is {ANENUM_A_REPR} which has all the following properties"
565+
))))
558566
)
559567
}
560568

integration_tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ googletest = { path = "../googletest", version = "0.10.0", features = ["anyhow"]
3232
anyhow = "1"
3333
indoc = "2"
3434
rstest = "0.18"
35+
rustversion = "1.0.14"
3536
tokio = { version = "1.34", features = ["time", "macros", "rt"] }
3637

3738
[[bin]]

integration_tests/src/integration_tests.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ mod tests {
474474
}
475475

476476
#[test]
477+
#[rustversion::before(1.76)]
477478
fn verify_pred_should_show_correct_qualified_function_name_in_test_failure_output() -> Result<()>
478479
{
479480
let output = run_external_process_in_tests_directory(
@@ -490,6 +491,24 @@ mod tests {
490491
)
491492
}
492493

494+
#[test]
495+
#[rustversion::since(1.76)]
496+
fn verify_pred_should_show_correct_qualified_function_name_in_test_failure_output() -> Result<()>
497+
{
498+
let output = run_external_process_in_tests_directory(
499+
"verify_predicate_with_failure_as_method_in_submodule",
500+
)?;
501+
502+
verify_that!(
503+
output,
504+
contains_substring(indoc! {"
505+
a_submodule::A_STRUCT_IN_SUBMODULE.eq_predicate_as_method(a, b) was false with
506+
a = 1,
507+
b = 2
508+
"})
509+
)
510+
}
511+
493512
#[test]
494513
fn fail_macro_causes_test_failure() -> Result<()> {
495514
let status = run_external_process("failure_due_to_fail_macro").status()?;

0 commit comments

Comments
 (0)