Skip to content

Commit bdd7927

Browse files
Update libtest-mimic to 0.5.2 (#5)
* Update libtest-mimic to 0.5.2 * Fix clippy warnings * Bump MSRV to 1.58 (required by libtest-mimic 0.5)
1 parent 17eddb5 commit bdd7927

File tree

6 files changed

+14
-26
lines changed

6 files changed

+14
-26
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ jobs:
3838
strategy:
3939
matrix:
4040
os: [ ubuntu-latest, macos-latest, windows-latest ]
41-
# 1.56 is the MSRV
42-
rust-version: [ 1.56, stable ]
41+
# 1.58 is the MSRV
42+
rust-version: [ 1.58, stable ]
4343
fail-fast: false
4444
env:
4545
RUSTFLAGS: -D warnings

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ categories = ["development-tools::testing"]
1111
keywords = ["datatest", "data-driven-tests", "test-harness"]
1212

1313
[dependencies]
14-
libtest-mimic = "0.4.0"
14+
libtest-mimic = "0.5.2"
1515
regex = "1.5.4"
1616
walkdir = "2.3.2"
1717

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ datatest_stable::harness!(my_test, "path/to/fixtures", r"^.*/*");
5656

5757
## Minimum supported Rust version (MSRV)
5858

59-
The minimum supported Rust version is **Rust 1.56**. MSRV bumps may be accompanied by a minor
59+
The minimum supported Rust version is **Rust 1.58**. MSRV bumps may be accompanied by a minor
6060
version update; at any time, at least the last 3 stable versions of Rust will be supported.
6161

6262
## See also

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
//!
5454
//! # Minimum supported Rust version (MSRV)
5555
//!
56-
//! The minimum supported Rust version is **Rust 1.56**. MSRV bumps may be accompanied by a minor
56+
//! The minimum supported Rust version is **Rust 1.58**. MSRV bumps may be accompanied by a minor
5757
//! version update; at any time, at least the last 3 stable versions of Rust will be supported.
5858
//!
5959
//! # See also

src/runner.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
#![allow(clippy::integer_arithmetic)]
55

66
use crate::{utils, Result};
7-
use libtest_mimic::{run_tests, Arguments, Outcome, Test};
7+
use libtest_mimic::{Arguments, Trial};
88
use std::path::Path;
99

1010
#[doc(hidden)]
1111
pub fn runner(requirements: &[Requirements]) {
1212
let args = Arguments::from_args();
1313

1414
let mut tests: Vec<_> = requirements.iter().flat_map(|req| req.expand()).collect();
15-
tests.sort_unstable_by(|a, b| a.name.cmp(&b.name));
15+
tests.sort_unstable_by(|a, b| a.name().cmp(b.name()));
1616

17-
run_tests(&args, tests, |test| (test.data)()).exit()
17+
libtest_mimic::run(&args, tests).exit()
1818
}
1919

2020
#[doc(hidden)]
@@ -43,7 +43,7 @@ impl Requirements {
4343

4444
/// Scans all files in a given directory, finds matching ones and generates a test descriptor
4545
/// for each of them.
46-
fn expand(&self) -> Vec<Test<Box<dyn Fn() -> Outcome + Send + Sync>>> {
46+
fn expand(&self) -> Vec<Trial> {
4747
let root = Path::new(&self.root).to_path_buf();
4848

4949
let re = regex::Regex::new(&self.pattern)
@@ -55,21 +55,10 @@ impl Requirements {
5555
if re.is_match(&input_path) {
5656
let testfn = self.test;
5757
let name = utils::derive_test_name(&root, &path, &self.test_name);
58-
let testfn: Box<dyn Fn() -> Outcome + Send + Sync> =
59-
Box::new(move || match (testfn)(&path) {
60-
Ok(()) => Outcome::Passed,
61-
Err(err) => Outcome::Failed {
62-
msg: Some(format!("{}", err)),
63-
},
64-
});
6558

66-
Some(Test {
67-
name,
68-
kind: String::new(),
69-
is_ignored: false,
70-
is_bench: false,
71-
data: testfn,
72-
})
59+
Some(Trial::test(name, move || {
60+
(testfn)(&path).map_err(Into::into)
61+
}))
7362
} else {
7463
None
7564
}

src/utils.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ pub fn derive_test_name(root: &Path, path: &Path, test_name: &str) -> String {
2727
path.display()
2828
)
2929
});
30-
let mut test_name = test_name.to_string();
31-
test_name.push_str(&format!("::{}", relative.display()));
32-
test_name
30+
31+
format!("{}::{}", test_name, relative.display())
3332
}

0 commit comments

Comments
 (0)