-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the 'pretty-assertions' crate #96
Comments
I was thinking of refactoring the way errors are printed to stdout/err if that is not included in #97, we can include this in the same refactor and I think we can also just add this as a dev dependency so it will only be included in the binary that gets built with |
#97 looks pretty separate to me 👍🏻 Come to think of it, it would be nice to enforce the usage of |
I don't know of any but this can be caught in review too. |
Looks like we can use My plan would be the following:
If this works — great! If not, we need to regroup and think 🤔 I'm not feeling confident in catching such kinds of problems during the review. There's too much I can remember to think about while reviewing the code 😞 |
Unless Im doing something wrong I can't seem to get clippy to run on tests. #[cfg(test)]
mod tests {
#![deny(clippy::disallowed_methods)]
use super::*; $ cat .clippy.toml
disallowed-methods = [
"std::assert_eq",
"std::assert_ne",
"std::assert_str_eq",
"std::boxed::Box::new",
] #![deny(clippy::disallowed_methods)]
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
use std::fs;
use std::path::PathBuf;
use toml::{map::Map, Value};
use crate::config::schema::{Config, ConfigAsset};
use crate::infra::err;
use crate::model::asset_name::AssetName;
#[derive(Debug, PartialEq, Eq)]
pub enum TomlError {
IO(String),
Parse(toml::de::Error),
Decode,
}
impl Display for TomlError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let _: std::boxed::Box<String> = std::boxed::Box::new(String::new());
match self {
TomlError::IO(e) => write!(f, "[IO Error] {}", e),
TomlError::Parse(e) => write!(f, "[Parsing Error] {}", e),
TomlError::Decode => write!(f, "[Decode Error]"),
}
}
} $ cargo clippy
Checking tool-sync v0.2.0 (/home/mitchell/rust/tool-sync)
error: use of a disallowed method `std::boxed::Box::new`
--> src/config/toml.rs:23:42
|
23 | let _: std::boxed::Box<String> = std::boxed::Box::new(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> src/config/toml.rs:1:9
|
1 | #![deny(clippy::disallowed_methods)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
warning: use of a disallowed method `std::boxed::Box::new`
--> src/lib.rs:24:26
|
24 | let _: Box<String> = Box::new(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::disallowed_methods)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
warning: `tool-sync` (lib) generated 1 warning
error: could not compile `tool-sync` due to previous error; 1 warning emitted $ cargo clippy --tests
Checking tool-sync v0.2.0 (/home/mitchell/rust/tool-sync)
error: use of a disallowed method `std::boxed::Box::new`
--> src/config/toml.rs:23:42
|
23 | let _: std::boxed::Box<String> = std::boxed::Box::new(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> src/config/toml.rs:1:9
|
1 | #![deny(clippy::disallowed_methods)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
warning: `assert!(false, ..)` should probably be replaced
--> src/config/toml.rs:178:17
|
178 | assert!(false, "Unexpected succces")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::assertions_on_constants)]` on by default
= help: use `panic!(..)` or `unreachable!(..)`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
warning: `assert!(true)` will be optimized out by the compiler
--> src/config/toml.rs:181:17
|
181 | assert!(true, "Exepected a parsing error")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: remove it
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
warning: use of a disallowed method `std::boxed::Box::new`
--> src/lib.rs:24:26
|
24 | let _: Box<String> = Box::new(String::new());
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::disallowed_methods)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
warning: `tool-sync` (lib) generated 1 warning
error: could not compile `tool-sync` due to previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
warning: `tool-sync` (lib test) generated 3 warnings (1 duplicate)
error: could not compile `tool-sync` due to previous error; 3 warnings emitted |
@MitchellBerend I found this It suggests that there's a hidden option |
I did, its the last output in the previous comment. |
Oh, didn't notice 😮 |
This package provides a better UX for failing tests.
Honestly, I think it should be the default. But it's possible to use this crate only for tests and not for users so it shouldn't affect people install
tool-sync
withcargo install
.The text was updated successfully, but these errors were encountered: