la10736 / rstest

Fixture-based test framework for Rust
Apache License 2.0
1.21k stars 43 forks source link

New #[files] feature does not recompile on file change #220

Open GeeWee opened 1 year ago

GeeWee commented 1 year ago

I have a large project with many files that I read as integration tests.

I saw the new #[files] feature and love it.

However, I would expect it to automatically pick up when I add new files to a directory that matches the glob pattern. This does currently seem to happen. If I add a file and run the (already compiled) crate, I do not get the new test case. However if I go in and force the crate to recompile by changing some arbitrary line of code, then the new test case seems to run.

I should probably mention here that my test files are outside the src directory, in a separate tests directory. I'm unsure if cargo picks up on the changed files automatically if they are all inside src

My current workaround is just to call touch src/lib.rs before running the tests, as that seems to force cargo to recompile.

la10736 commented 1 year ago

Sorry, isn't possible to handle this without introducing a build.rs script :cry: In this script we should define the folder that we want to handle and add a variable that should reflect the last state like an hash (but may there is already something about that in some crates).

That's really sad....

GeeWee commented 1 year ago

Yes I also couldn't quite figure it out how to do it in a sensible way without a build.rs script either :( Might be worth documenting this though, as it took me a little while to figure out the behaviour.

GeeWee commented 1 year ago

It does look like something nightly-only exists which might be stabilized at some point, not sure if we can do much except wait for that.

la10736 commented 1 year ago

Yes... but maybe is not enough because you can track files but not folder.

GeeWee commented 1 year ago

Seems like it does allow for folder tracking, but it might not support globbing, which is unfortunate.

la10736 commented 5 months ago

In #256 I wrote some notes about how to handle this in the most of the cases. Intended, with the use of build.rs script.