-
Notifications
You must be signed in to change notification settings - Fork 43
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
Dynamic set of tests #39
Comments
I would also love to see this feature implemented. |
I know that lot of people love/need this kind of feature. But unfortunately this feature cannot implemented just by use procedural macro. The code that you wrote cannot work because procedural macro are executed in the early compile time stage but your code relay on the run time resolution of The only way to implemented a feature like this is to introduce a The completely dynamic implementation (not just files) is impossible without implement a custom test hardness 😢 |
Right. The baked-in This would require making a (backward-compatible, relatively minor) change in the way Variants of this have been requested for a long time (e.g. https://internals.rust-lang.org/t/pre-rfc-dynamic-tests/6790 is 4 years old), to o avail. It seems that Rust's answer to "dynamic tests" is to require switching to a different test harness. For example https://docs.rs/datatest/0.7.1/datatest/ which, alas, requires nightly 😢 Perhaps they would be amenable to a minimal pull request to overcome this - it does seem like a minor change - but even so, such a thing would spend a long time in nightly before it would be added into stable... |
I posted https://internals.rust-lang.org/t/dynamic-tests-revisited/18095 to see whether there's any chance of this getting (eventually) supported. Don't hold your breath :-) Looking at it again, it seems that by hijacking |
In general the pattern would be:
This isn't just an alternative syntax, it allows computing a dynamic set of cases. In my use case, each test case is derived from a disk directory containing input files and expected output files. Right now, every time I create a new such test directory, I have to also write a silly:
Admittedly using
rtest
would reduce this overhead to just adding a single linecase("foo")
in a list, but it would still be best if I could just useglob
to generate this list at run time, so just creating the directory would suffice.However, this means that
rtest_from
can't work in the way described above; as a compile macro it has no way to access the dynamic values inTEST_CASES
and therefore it can't "simply" generate a static test case function for each one.Google search did not locate any way to generate a dynamic list of tests... is it even possible?
Originally posted by @orenbenkiki in #37 (comment)
The text was updated successfully, but these errors were encountered: