Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 7 additions & 18 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#![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)]
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)]
Expand Down Expand Up @@ -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<Test<Box<dyn Fn() -> Outcome + Send + Sync>>> {
fn expand(&self) -> Vec<Trial> {
let root = Path::new(&self.root).to_path_buf();

let re = regex::Regex::new(&self.pattern)
Expand All @@ -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<dyn Fn() -> 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
}
Expand Down
5 changes: 2 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}