From 7a55e3b29600f6032a6928ccdee7887aa1365d99 Mon Sep 17 00:00:00 2001 From: Eduardo Trujillo <ed@chromabits.com> Date: Mon, 21 Nov 2022 15:30:23 -0800 Subject: [PATCH] chore: Address clippy lints in tests --- .gitlab-ci.yml | 2 +- src/lib.rs | 2 ++ src/rundir.rs | 16 ++++++++-------- src/str.rs | 2 +- src/thread/handle.rs | 4 ++-- src/thread/monitor.rs | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2699d4..866dc01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -65,7 +65,7 @@ rust-nightly-clippy: - target/ <<: *rust_template script: - - cargo clippy --all --verbose -- -D warnings + - cargo clippy --all --tests --verbose -- -D warnings pages: stage: build diff --git a/src/lib.rs b/src/lib.rs index fe83c57..50b2c9f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms, nonstandard_style)] +#![warn(future_incompatible)] #![doc = include_str!("../README.md")] /// CLI application utilities. diff --git a/src/rundir.rs b/src/rundir.rs index 7d1db45..35179da 100644 --- a/src/rundir.rs +++ b/src/rundir.rs @@ -225,7 +225,7 @@ mod tests { use std::path::PathBuf; #[test] - fn test_initialize() -> () { + fn test_initialize() { // Create dir for the first time. let result = RunDir::new("tests/rundir").initialize(); @@ -272,21 +272,21 @@ mod tests { } #[test] - fn test_subdirs() -> () { + fn test_subdirs() { let rundir = RunDir::new("tests/rundir2").allow_cleaning(true); rundir.initialize().unwrap(); - assert_eq!(PathBuf::from("tests/rundir2/subtest").exists(), false); - assert_eq!(rundir.subdir_exists("subtest").unwrap(), false); + assert!(!PathBuf::from("tests/rundir2/subtest").exists()); + assert!(!rundir.subdir_exists("subtest").unwrap()); rundir.create_subdir("subtest").unwrap(); - assert_eq!(PathBuf::from("tests/rundir2/subtest").exists(), true); - assert_eq!(rundir.subdir_exists("subtest").unwrap(), true); + assert!(PathBuf::from("tests/rundir2/subtest").exists()); + assert!(rundir.subdir_exists("subtest").unwrap()); rundir.remove_subdir_all("subtest").unwrap(); - assert_eq!(PathBuf::from("tests/rundir2/subtest").exists(), false); - assert_eq!(rundir.subdir_exists("subtest").unwrap(), false); + assert!(!PathBuf::from("tests/rundir2/subtest").exists()); + assert!(!rundir.subdir_exists("subtest").unwrap()); rundir.cleanup().unwrap(); } diff --git a/src/str.rs b/src/str.rs index b5d4be9..d78ce45 100644 --- a/src/str.rs +++ b/src/str.rs @@ -14,7 +14,7 @@ mod test { use super::*; #[test] - fn test_to_train_case() -> () { + fn test_to_train_case() { assert_eq!(to_train_case("omg-OMG_omg123 omg"), "OMG_OMG_OMG123_OMG") } } diff --git a/src/thread/handle.rs b/src/thread/handle.rs index ea51990..8dac14c 100644 --- a/src/thread/handle.rs +++ b/src/thread/handle.rs @@ -154,7 +154,7 @@ mod tests { let end_handle = handle.get_end_handle(); - assert_eq!((&end_handle).has_ended(), Ok(false)); + assert_eq!(end_handle.has_ended(), Ok(false)); end_tx.send(()).unwrap(); @@ -181,7 +181,7 @@ mod tests { end_handles.insert(handle.thread().id(), handle.get_end_handle()); } - for (_, end_handle) in &end_handles { + for end_handle in end_handles.values() { assert_eq!(end_handle.has_ended(), Ok(false)); } diff --git a/src/thread/monitor.rs b/src/thread/monitor.rs index b81e01e..c2cf0d6 100644 --- a/src/thread/monitor.rs +++ b/src/thread/monitor.rs @@ -226,7 +226,7 @@ mod tests { let test_handle = thread::spawn(move || { let watch_result = MONITOR.watch(Some(&thread_ids)).unwrap(); - assert_eq!(watch_result.is_empty(), false); + assert!(!watch_result.is_empty()); assert_eq!(watch_result[0].id(), handle.thread().id()); }); -- GitLab