From 485ff8375516c0c05b45f58e96dede1af38aebea Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sat, 13 Aug 2022 16:44:11 +0200 Subject: [PATCH 1/3] Update libtest-mimic to 0.5.2 --- Cargo.toml | 2 +- src/runner.rs | 25 +++++++------------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index aee18e48d..2912537b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ categories = ["development-tools::testing"] keywords = ["datatest", "data-driven-tests", "test-harness"] [dependencies] -libtest-mimic = "0.4.0" +libtest-mimic = "0.5.2" regex = "1.5.4" walkdir = "2.3.2" diff --git a/src/runner.rs b/src/runner.rs index 513af7aa6..99c90d790 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -4,7 +4,7 @@ #![allow(clippy::integer_arithmetic)] use crate::{utils, Result}; -use libtest_mimic::{run_tests, Arguments, Outcome, Test}; +use libtest_mimic::{Arguments, Trial}; use std::path::Path; #[doc(hidden)] @@ -12,9 +12,9 @@ pub fn runner(requirements: &[Requirements]) { let args = Arguments::from_args(); let mut tests: Vec<_> = requirements.iter().flat_map(|req| req.expand()).collect(); - tests.sort_unstable_by(|a, b| a.name.cmp(&b.name)); + tests.sort_unstable_by(|a, b| a.name().cmp(&b.name())); - run_tests(&args, tests, |test| (test.data)()).exit() + libtest_mimic::run(&args, tests).exit() } #[doc(hidden)] @@ -43,7 +43,7 @@ impl Requirements { /// Scans all files in a given directory, finds matching ones and generates a test descriptor /// for each of them. - fn expand(&self) -> Vec Outcome + Send + Sync>>> { + fn expand(&self) -> Vec { let root = Path::new(&self.root).to_path_buf(); let re = regex::Regex::new(&self.pattern) @@ -55,21 +55,10 @@ impl Requirements { if re.is_match(&input_path) { let testfn = self.test; let name = utils::derive_test_name(&root, &path, &self.test_name); - let testfn: Box Outcome + Send + Sync> = - Box::new(move || match (testfn)(&path) { - Ok(()) => Outcome::Passed, - Err(err) => Outcome::Failed { - msg: Some(format!("{}", err)), - }, - }); - Some(Test { - name, - kind: String::new(), - is_ignored: false, - is_bench: false, - data: testfn, - }) + Some(Trial::test(name, move || { + (testfn)(&path).map_err(Into::into) + })) } else { None } From 9a7ff0db9ed10da0ce62c3ddd838888be3b642e0 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Mon, 15 Aug 2022 17:09:17 +0200 Subject: [PATCH 2/3] Fix clippy warnings --- src/runner.rs | 2 +- src/utils.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/runner.rs b/src/runner.rs index 99c90d790..8918a3157 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -12,7 +12,7 @@ pub fn runner(requirements: &[Requirements]) { let args = Arguments::from_args(); let mut tests: Vec<_> = requirements.iter().flat_map(|req| req.expand()).collect(); - tests.sort_unstable_by(|a, b| a.name().cmp(&b.name())); + tests.sort_unstable_by(|a, b| a.name().cmp(b.name())); libtest_mimic::run(&args, tests).exit() } diff --git a/src/utils.rs b/src/utils.rs index 1bdbc2cab..5d2be6af1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -27,7 +27,6 @@ pub fn derive_test_name(root: &Path, path: &Path, test_name: &str) -> String { path.display() ) }); - let mut test_name = test_name.to_string(); - test_name.push_str(&format!("::{}", relative.display())); - test_name + + format!("{}::{}", test_name, relative.display()) } From 6ea34fba9bb1523f0d7e4da7416f447afcb49e29 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Mon, 15 Aug 2022 17:27:37 +0200 Subject: [PATCH 3/3] Bump MSRV to 1.58 (required by libtest-mimic 0.5) --- .github/workflows/ci.yml | 4 ++-- README.md | 2 +- src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a25f78e7..c052a1291 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,8 +38,8 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - # 1.56 is the MSRV - rust-version: [ 1.56, stable ] + # 1.58 is the MSRV + rust-version: [ 1.58, stable ] fail-fast: false env: RUSTFLAGS: -D warnings diff --git a/README.md b/README.md index 36da8efe7..5930fd2fc 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ datatest_stable::harness!(my_test, "path/to/fixtures", r"^.*/*"); ## Minimum supported Rust version (MSRV) -The minimum supported Rust version is **Rust 1.56**. MSRV bumps may be accompanied by a minor +The minimum supported Rust version is **Rust 1.58**. MSRV bumps may be accompanied by a minor version update; at any time, at least the last 3 stable versions of Rust will be supported. ## See also diff --git a/src/lib.rs b/src/lib.rs index 70d4d4039..4bdb128c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ //! //! # Minimum supported Rust version (MSRV) //! -//! The minimum supported Rust version is **Rust 1.56**. MSRV bumps may be accompanied by a minor +//! The minimum supported Rust version is **Rust 1.58**. MSRV bumps may be accompanied by a minor //! version update; at any time, at least the last 3 stable versions of Rust will be supported. //! //! # See also