mindsbackyard / galvanic-test

A test environment for rust: test cases & suites, fixtures, and parameterised test cases
Apache License 2.0
52 stars 3 forks source link

`galvanic-test` generates warnings in strict build environment #8

Closed U007D closed 5 years ago

U007D commented 7 years ago

I've seen compiler warnings avert disasters, and set them strictly. Unfortunately, when set this way, test_suite! generates a number of warnings:

warning: unnecessary qualification
  --> src/lib/unit_tests/mod.rs:39:1
   |
39 | / test_suite! {
40 | |     name app_tests_wo_fixtures;
41 | |     use super::*;
42 | |
...  |
62 | |     }
63 | | }
   | |_^
   |
note: lint level defined here
  --> src/lib/quickstart_template.rs:11:81
   |
11 |         /*use_debug,*/ use_self, used_underscore_binding, unused_import_braces, unused_qualifications,
   |                                                                                 ^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in a macro outside of the current crate

warning: trivial cast: `&unit_tests::app_tests_wo_fixtures::mod_with_mocks::mock::GivenBehaviour` as `&unit_tests::app_tests_wo_fixtures::mod_with_mocks::mock::GivenBehaviour`. Cast can be replaced by coercion, this might require type ascription or a temporary variable
  --> src/lib/unit_tests/mod.rs:39:1
   |
39 | / test_suite! {
40 | |     name app_tests_wo_fixtures;
41 | |     use super::*;
42 | |
...  |
62 | |     }
63 | | }
   | |_^
   |
note: lint level defined here
  --> src/lib/quickstart_template.rs:9:96
   |
9  |         pub_enum_variant_names, range_plus_one, result_map_unwrap_or_else, result_unwrap_used, trivial_casts,
   |                                                                                                ^^^^^^^^^^^^^
   = note: this error originates in a macro outside of the current crate

warning: redundant closure found
  --> src/lib/unit_tests/mod.rs:39:1
   |
39 | / test_suite! {
40 | |     name app_tests_wo_fixtures;
41 | |     use super::*;
42 | |
...  |
62 | |     }
63 | | }
   | |_^ help: remove closure as shown: `# [ use_mocks ]`
   |
   = note: #[warn(redundant_closure)] on by default
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#redundant_closure
   = note: this error originates in a macro outside of the current crate

warning: redundant closure found
  --> src/lib/unit_tests/mod.rs:39:1
   |
39 | / test_suite! {
40 | |     name app_tests_wo_fixtures;
41 | |     use super::*;
42 | |
...  |
62 | |     }
63 | | }
   | |_^ help: remove closure as shown: `# [ use_mocks ]`
   |
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#redundant_closure
   = note: this error originates in a macro outside of the current crate

    Finished dev [unoptimized + debuginfo] target(s) in 1.20 secs

Specifically, galvanic-test is triggering the following warnings: redundant_closure, trivial_casts, unused_qualifications.

mindsbackyard commented 6 years ago

Hi, could you please provide the rust version/channel you are using? Any compiler flags and are you using clippy?

On 21 Nov 2017 00:07, "Brad Gibson" notifications@github.com wrote:

I've seen compiler warnings avert disasters, and set them strictly. Unfortunately, when set this way, test_suite! generates a number of warnings:

warning: unnecessary qualification --> src/lib/unit_tests/mod.rs:39:1 39 / test_suite! { 40 name app_tests_wo_fixtures; 41 use super::*; 42 ... 62 } 63 } _^

note: lint level defined here --> src/lib/quickstart_template.rs:11:81 | 11 | /use_debug,/ use_self, used_underscore_binding, unused_import_braces, unused_qualifications, | ^^^^^^^^^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate

warning: trivial cast: &unit_tests::app_tests_wo_fixtures::mod_with_mocks::mock::GivenBehaviour as &unit_tests::app_tests_wo_fixtures::mod_with_mocks::mock::GivenBehaviour. Cast can be replaced by coercion, this might require type ascription or a temporary variable --> src/lib/unit_tests/mod.rs:39:1 39 / test_suite! { 40 name app_tests_wo_fixtures; 41 use super::*; 42 ... 62 } 63 } _^

note: lint level defined here --> src/lib/quickstart_template.rs:9:96 | 9 | pub_enum_variant_names, range_plus_one, result_map_unwrap_or_else, result_unwrap_used, trivial_casts, | ^^^^^^^^^^^^^ = note: this error originates in a macro outside of the current crate

warning: redundant closure found --> src/lib/unit_tests/mod.rs:39:1 39 / test_suite! { 40 name app_tests_wo_fixtures; 41 use super::*; 42 ... 62 } 63 } _^ help: remove closure as shown: # [ use_mocks ]

= note: #[warn(redundant_closure)] on by default = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#redundant_closure = note: this error originates in a macro outside of the current crate

warning: redundant closure found --> src/lib/unit_tests/mod.rs:39:1 39 / test_suite! { 40 name app_tests_wo_fixtures; 41 use super::*; 42 ... 62 } 63 } _^ help: remove closure as shown: # [ use_mocks ]

= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#redundant_closure = note: this error originates in a macro outside of the current crate

Finished dev [unoptimized + debuginfo] target(s) in 1.20 secs

Specifically, galvanic-test is triggering the following warnings: redundant_closure, trivial_casts, unused_qualifications.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mindsbackyard/galvanic-test/issues/8, or mute the thread https://github.com/notifications/unsubscribe-auth/AVk9N_3l8csGRqDeuLvBCQNRxbHQHu-Bks5s4gZFgaJpZM4QlCee .

U007D commented 6 years ago

Yes, I'm using clippy. Clippy settings:

#![cfg_attr(feature="clippy", feature(plugin))] //nightly rustc required by `clippy`
#![cfg_attr(feature="clippy", plugin(clippy))]
#![feature(proc_macro, galvanic_mock_integration, const_atomic_bool_new)] //req'd by galvanic-mock, galvanic-test + galvanic-mock
#![allow(unused_imports)] //disable false positives
#![warn(cast_possible_truncation, cast_possible_wrap, cast_precision_loss, cast_sign_loss, empty_enum, enum_glob_use,
        fallible_impl_from, filter_map, if_not_else, int_plus_one, invalid_upcast_comparisons, maybe_infinite_iter,
        mem_forget, missing_debug_implementations, mut_mut, mutex_integer, nonminimal_bool, option_map_unwrap_or,
        option_map_unwrap_or_else, option_map_unwrap_or_else, option_unwrap_used, /*print_stdout,*/
        pub_enum_variant_names, range_plus_one, result_map_unwrap_or_else, result_unwrap_used, trivial_casts,
        non_camel_case_types, stutter, trivial_numeric_casts, unicode_not_nfc, unseparated_literal_suffix,
        /*use_debug,*/ use_self, used_underscore_binding, unused_import_braces, unused_qualifications,
        wrong_pub_self_convention)]
#![deny(overflowing_literals, unused_must_use)]

rustc 1.23.0-nightly (79cfce3d3 2017-11-12)

Build is command used was cargo test --features clippy

U007D commented 6 years ago

Also now seeing:

warning: The function/method `noop` doesn't need a mutable reference
  --> src/lib/unit_tests/mod.rs:6:1
   |
6  | / test_suite! {
7  | |     name app_tests;
8  | |     use super::*;
9  | |
...  |
33 | |     }
34 | | }
   | |_^
   |
   = note: #[warn(unnecessary_mut_passed)] on by default
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#unnecessary_mut_passed
   = note: this error originates in a macro outside of the current crate

    Finished dev [unoptimized + debuginfo] target(s) in 1.45 secs
     Running target/debug/deps/quickstart_template-cc81a3e1aadaaff6

To facilitate repro here is the branch/commit which yields this issue: https://github.com/U007D/qst/tree/2892a8b3225d97e710d8105763b82e2944a620c5

mindsbackyard commented 6 years ago

The library was not yet sanitized with clippy, just with the standard warnings. At some point this should probably be done.

On 21 Nov 2017 18:26, "Brad Gibson" notifications@github.com wrote:

Also now seeing:

warning: The function/method noop doesn't need a mutable reference --> src/lib/unit_tests/mod.rs:6:1 6 / test_suite! { 7 name app_tests; 8 use super::*; 9 ... 33 } 34 } _^

= note: #[warn(unnecessary_mut_passed)] on by default = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.170/index.html#unnecessary_mut_passed = note: this error originates in a macro outside of the current crate

Finished dev [unoptimized + debuginfo] target(s) in 1.45 secs
 Running target/debug/deps/quickstart_template-cc81a3e1aadaaff6

To facilitate repro here is the commit which yields this issue: https://github.com/U007D/qst/tree/2892a8b3225d97e710d8105763b82e2944a620c5

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mindsbackyard/galvanic-test/issues/8#issuecomment-346100001, or mute the thread https://github.com/notifications/unsubscribe-auth/AVk9N9UkQeraA29yczck4zbnoWtdYx8fks5s4weqgaJpZM4QlCee .

U007D commented 6 years ago

Ah, ok, good to know. I won't bother spamming you by posting any more of these that come up until perhaps after the clippy pass sometime in the future. I'll let you leave this issue open or close as appropriate.

In the meantime, I'll try to suppress these on my end on a case-by-case basis.

Thanks, @mindsbackyard.

mindsbackyard commented 5 years ago

With the the new Rust edition 2018 (1.31.1), I've run cargo clippy with default settings and no warnings or errors show up. I guess this issue can be closed.