Skip to content
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

feat: regex pattern additional syntax support #43

Merged
merged 9 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
40 changes: 27 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ rust-version = "1.65"

[dependencies]
camino = "1.1.6"
fancy-regex = "0.13.0"
libtest-mimic = "0.7.2"
regex = "1.10.4"
walkdir = "2.5.0"

[[test]]
Expand Down
4 changes: 2 additions & 2 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ 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<Trial> {
let re = regex::Regex::new(&self.pattern)
let re = fancy_regex::Regex::new(&self.pattern)
.unwrap_or_else(|_| panic!("invalid regular expression: '{}'", self.pattern));

let tests: Vec<_> = utils::iterate_directory(&self.root)
.filter_map(|path_res| {
let path = path_res.expect("error while iterating directory");
if re.is_match(path.as_str()) {
if re.is_match(path.as_str()).unwrap_or_else(|_| panic!("Problem with matching following pattern : '{}'", self.pattern)) {
Copy link
Member

@sunshowers sunshowers Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also include the path being matched against, and should be phrased as something like:

error matching pattern '{}' against path '{}': {}

And do include the error as well -- it'll most likely be a VM limit exceeded error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

let testfn = self.test;
let name = utils::derive_test_name(&self.root, &path, &self.test_name);
Some(Trial::test(name, move || {
Expand Down
4 changes: 2 additions & 2 deletions tests/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fn test_artifact_utf8(path: &Utf8Path) -> Result<()> {
datatest_stable::harness!(
test_artifact,
"tests/files",
r"^.*/*",
r"^.*(?<!\.skip)\.txt",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make one of them a regular regex? That way we get to see both of the outcomes.

test_artifact_utf8,
"tests/files",
r"^.*/*",
r"^.*(?<!\.skip)\.txt",
);
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions tests/files/c.skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
baz foo