From f202f473ae42ade31cdd6b91a0e10b347cc2d6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Biel?= Date: Sun, 17 Sep 2023 01:14:34 +0300 Subject: [PATCH] chore: fix clippy and tests --- crates/test-case-core/src/test_case.rs | 2 +- ...nce__cases_can_be_declared_on_non_test_items.snap | 6 +++--- .../rust-nightly/acceptance__cases_can_panic.snap | 4 ++-- .../acceptance__cases_can_use_regex.snap | 12 +++++++----- ...cases_declared_on_non_test_items_can_be_used.snap | 4 ++-- ...acceptance__cases_support_complex_assertions.snap | 4 ++-- .../acceptance__cases_support_pattern_matching.snap | 7 ++++--- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/crates/test-case-core/src/test_case.rs b/crates/test-case-core/src/test_case.rs index b9b643a..105d421 100644 --- a/crates/test-case-core/src/test_case.rs +++ b/crates/test-case-core/src/test_case.rs @@ -72,7 +72,7 @@ impl TestCase { .expression .as_ref() .map(|expr| expr.attributes()) - .unwrap_or_else(Vec::new); + .unwrap_or_default(); attrs.push(parse_quote! { #[allow(clippy::bool_assert_comparison)] }); attrs.append(&mut item.attrs); diff --git a/tests/snapshots/rust-nightly/acceptance__cases_can_be_declared_on_non_test_items.snap b/tests/snapshots/rust-nightly/acceptance__cases_can_be_declared_on_non_test_items.snap index 02edc37..bcb6f87 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_can_be_declared_on_non_test_items.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_can_be_declared_on_non_test_items.snap @@ -1,12 +1,12 @@ --- source: tests/acceptance_tests.rs -assertion_line: 78 expression: output --- internal_tested_function1::_3_expects_6 left: `6`, - right: `0`', src/lib.rs:8:1 + right: `0` ---- internal_tested_function1::_3_expects_6 stdout ---- +assertion failed: `(left == right)` error: test failed, to rerun pass `--lib` failures: failures: @@ -18,4 +18,4 @@ test internal_tested_function3::_1_expects_matching_3_ ... ok test internal_tested_function3::_2_expects_inconclusive6 ... ignored test internal_tested_function4::_2_expects_panicking_some_can_t_ - should panic ... ok test result: FAILED. 4 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s -thread 'internal_tested_function1::_3_expects_6' panicked at 'assertion failed: `(left == right)` +thread 'internal_tested_function1::_3_expects_6' panicked at src/lib.rs:8:1: diff --git a/tests/snapshots/rust-nightly/acceptance__cases_can_panic.snap b/tests/snapshots/rust-nightly/acceptance__cases_can_panic.snap index b1f50ab..f0d4b63 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_can_panic.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_can_panic.snap @@ -1,12 +1,12 @@ --- source: tests/acceptance_tests.rs -assertion_line: 93 expression: output --- panic message: `"It has to panic"`, panicing::_expects_panicking_some_this_should_fail_ expected substring: `"This should fail"` ---- panicing::_expects_panicking_some_this_should_fail_ stdout ---- +It has to panic error: test failed, to rerun pass `--lib` failures: failures: @@ -17,4 +17,4 @@ test panics_without_value::_expects_panicking_none - should panic ... ok test pattern_matching_result_fails::simpleenum_var1_expects_matching_simpleenum_var2_ - should panic ... ok test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result_which_panics::_2_2_expects_2_3 - should panic ... ok -thread 'panicing::_expects_panicking_some_this_should_fail_' panicked at 'It has to panic', src/lib.rs:20:5 +thread 'panicing::_expects_panicking_some_this_should_fail_' panicked at src/lib.rs:20:5: diff --git a/tests/snapshots/rust-nightly/acceptance__cases_can_use_regex.snap b/tests/snapshots/rust-nightly/acceptance__cases_can_use_regex.snap index 5adabe1..ffacf12 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_can_use_regex.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_can_use_regex.snap @@ -1,6 +1,5 @@ --- source: tests/acceptance_tests.rs -assertion_line: 138 expression: output --- / @@ -8,10 +7,13 @@ expression: output regex_test::_abcabc201_expects_complex_regex_r_d_4_ regex_test::_kumkwat_expects_complex_regex_r_ regex_test::_kumkwat_expects_complex_regex_r_abc_ -)', src/lib.rs:5:1 +) ---- regex_test::_abcabc201_expects_complex_regex_r_d_4_ stdout ---- ---- regex_test::_kumkwat_expects_complex_regex_r_ stdout ---- ---- regex_test::_kumkwat_expects_complex_regex_r_abc_ stdout ---- +Regex::new: Syntax( +assertion failed: {/n let re = ::test_case::Regex::new(r#/"//d{4}/"#).expect(/"Regex::new/");/n re.is_match(_result)/n} +assertion failed: {/n let re = ::test_case::Regex::new(r#/"abc/"#).expect(/"Regex::new/");/n re.is_match(_result)/n} error: incomplete escape sequence, reached end of pattern prematurely error: test failed, to rerun pass `--lib` failures: @@ -25,8 +27,8 @@ test regex_test::_kumkwat_expects_complex_regex_r_ ... FAILED test regex_test::_kumkwat_expects_complex_regex_r_abc_ ... FAILED test regex_test::_kumkwat_expects_complex_regex_r_kumkwat_ ... ok test result: FAILED. 3 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s -thread 'regex_test::_abcabc201_expects_complex_regex_r_d_4_' panicked at 'assertion failed: {/n let re = ::test_case::Regex::new(r#/"//d{4}/"#).expect(/"Regex::new/");/n re.is_match(_result)/n}', src/lib.rs:5:1 -thread 'regex_test::_kumkwat_expects_complex_regex_r_' panicked at 'Regex::new: Syntax( -thread 'regex_test::_kumkwat_expects_complex_regex_r_abc_' panicked at 'assertion failed: {/n let re = ::test_case::Regex::new(r#/"abc/"#).expect(/"Regex::new/");/n re.is_match(_result)/n}', src/lib.rs:5:1 +thread 'regex_test::_abcabc201_expects_complex_regex_r_d_4_' panicked at src/lib.rs:5:1: +thread 'regex_test::_kumkwat_expects_complex_regex_r_' panicked at src/lib.rs:5:1: +thread 'regex_test::_kumkwat_expects_complex_regex_r_abc_' panicked at src/lib.rs:5:1: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/snapshots/rust-nightly/acceptance__cases_declared_on_non_test_items_can_be_used.snap b/tests/snapshots/rust-nightly/acceptance__cases_declared_on_non_test_items_can_be_used.snap index dc77e31..1438828 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_declared_on_non_test_items_can_be_used.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_declared_on_non_test_items_can_be_used.snap @@ -1,7 +1,7 @@ --- source: tests/acceptance_tests.rs -assertion_line: 75 expression: output --- Running `target/debug/cases_can_be_declared_on_non_test_items` -thread 'main' panicked at 'Can't', src/lib.rs:33:5 +Can't +thread 'main' panicked at src/lib.rs:33:5: diff --git a/tests/snapshots/rust-nightly/acceptance__cases_support_complex_assertions.snap b/tests/snapshots/rust-nightly/acceptance__cases_support_complex_assertions.snap index 9caea52..33018a3 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_support_complex_assertions.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_support_complex_assertions.snap @@ -1,10 +1,10 @@ --- source: tests/acceptance_tests.rs -assertion_line: 108 expression: output --- empty::vec_0_expects_complex_empty ---- empty::vec_0_expects_complex_empty stdout ---- +assertion failed: _result.is_empty() error: test failed, to rerun pass `--lib` failures: failures: @@ -64,4 +64,4 @@ test not_path::_cargo_toml_parse_unwrap_expects_complex_not_path_dir ... ok test not_path::_cargo_yaml_parse_unwrap_expects_complex_not_path_path ... ok test not_path::_src_parse_unwrap_expects_complex_not_path_file ... ok test result: FAILED. 53 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s -thread 'empty::vec_0_expects_complex_empty' panicked at 'assertion failed: _result.is_empty()', src/lib.rs:115:1 +thread 'empty::vec_0_expects_complex_empty' panicked at src/lib.rs:115:1: diff --git a/tests/snapshots/rust-nightly/acceptance__cases_support_pattern_matching.snap b/tests/snapshots/rust-nightly/acceptance__cases_support_pattern_matching.snap index 725feaf..69ec108 100644 --- a/tests/snapshots/rust-nightly/acceptance__cases_support_pattern_matching.snap +++ b/tests/snapshots/rust-nightly/acceptance__cases_support_pattern_matching.snap @@ -1,12 +1,13 @@ --- source: tests/acceptance_tests.rs -assertion_line: 133 expression: output --- extended_pattern_matching_result::err_should_fail extended_pattern_matching_result::ok_should_fail ---- extended_pattern_matching_result::err_should_fail stdout ---- ---- extended_pattern_matching_result::ok_should_fail stdout ---- +Expected `Err(e) if e == "var1"` found Err("var2") +Expected `Ok(e) if e == SimpleEnum :: Var2` found Ok(Var1) error: test failed, to rerun pass `--lib` failures: failures: @@ -17,5 +18,5 @@ test extended_pattern_matching_result::simpleenum_var1_expects_matching_ok_e_e_s test extended_pattern_matching_result::simpleenum_var2_expects_matching_err_e_e_var2_ ... ok test pattern_matching_result::simpleenum_var2_expects_matching_simpleenum_var2_ ... ok test result: FAILED. 3 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s -thread 'extended_pattern_matching_result::err_should_fail' panicked at 'Expected `Err(e) if e == "var1"` found Err("var2")', src/lib.rs:16:1 -thread 'extended_pattern_matching_result::ok_should_fail' panicked at 'Expected `Ok(e) if e == SimpleEnum :: Var2` found Ok(Var1)', src/lib.rs:16:1 +thread 'extended_pattern_matching_result::err_should_fail' panicked at src/lib.rs:16:1: +thread 'extended_pattern_matching_result::ok_should_fail' panicked at src/lib.rs:16:1: