LukasKalbertodt / libtest-mimic

A small test framework to write your own test harness that looks and behaves like the built-in test harness used by `rustc --test`
https://docs.rs/libtest-mimic
Apache License 2.0
95 stars 26 forks source link

Public API for filtering without running #37

Open kpreid opened 3 months ago

kpreid commented 3 months ago

I have tests which I need to run in a custom way, and I'd like to be able to benefit from libtest-mimic's work to precisely emulate the standard test harness interface, but the most I can use, it seems, is using the public Arguments struct to parse arguments — there's no way to use the filtering implementation but not the runner.

Could you add a function which takes an Arguments and a set of test descriptions (like run()), and returns an iterator of which tests should be run, instead of running them? (Or in the case of --list, it would do the expected printing and return a value indicating to just exit.)

(It is of course already possible to insert placeholders as the individual test functions, but that would require each placeholder function to access global state for the real test harness, and to block until the test actually runs in order to report success/failure, which seems inelegant and potentially problematic.)