From 54d3970a949b0e6b6511d3de2398c4d7b1077adc Mon Sep 17 00:00:00 2001 From: David Anthoff Date: Sat, 1 Apr 2023 14:48:33 -0700 Subject: [PATCH] Add support for filter callback --- README.md | 2 +- src/TestItemRunner2.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c94ce44..e0ff2a3 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Runs test items. This will re-use client processes from a previous call to `run_ Args: - `path`: Filesystem path to a folder. -- `filter`: Not implemented right now. +- `filter`: A filter callback function that will be called for each identified test item. If the filter callback returns `true` that test item will be run, if `false` it will not run. Each call to the provided filter callback passes a named tuple argument with a number of fields that contain metadata about the specific test item. The provided information is `filename`, `name`, `tags` and `package_name`. - `verbose` Not implemented right now. - `max_workers`: Max number of child processes per identified project. - `timeout`: Timeout in seconds. diff --git a/src/TestItemRunner2.jl b/src/TestItemRunner2.jl index a7ea5fb..671a627 100644 --- a/src/TestItemRunner2.jl +++ b/src/TestItemRunner2.jl @@ -251,10 +251,10 @@ function run_tests(path; filter=nothing, verbose=false, max_workers::Int=Sys.CPU # Flat list of @testitems testitems = [(detail=i, code=get_text(jw._text_documents[i.uri])[i.code_range]) for i in Iterators.flatten(values(jw._testitems))] - # # Filter @testitems - # if filter !== nothing - # filter!(i->filter((filename=uri2filepath(i.detail.uri), name=i.detail.name, tags=i.detail.option_tags)), testitems) - # end + # Filter @testitems + if filter !== nothing + filter!(i->filter((filename=uri2filepath(i.detail.uri), name=i.detail.name, tags=i.detail.option_tags, package_name=i.detail.package_name)), testitems) + end executed_testitems = []