Hi folks I have some tests which rely on a file t...
# general
Hi folks I have some tests which rely on a file to work. I’ve specified this in the build file of the tests using the resource target. I can run the tests and it all works swimmingly. The trouble is I don’t want to include this file in git and when I run
./pants lint
it errors with a
InvalidFieldException: The 'source' field in target example/folder must have 1 file, but it had 0 files
. How can I tell pants to ignore this error and continue to lint even if the file doesn’t exist and is not in version control?
The file existing and tracking in git or not are two separate things.
We did something similar for a compiled binary that we placed next to one of our modules that it needed.
But we didn't want to track that in git so we had it in
However, we still included it with the
entry in our
We had an entry like
Thanks for the replies 😃. But i don't think any of the suggestion work for my case. I need the binary to be recognised by pants when I run tests, since the tests require that binary. That binary is only created at the beginning of the tests and then removed at the end of the tests. To do this we run
pants package
just before we run
pants test
to create the binary. But i don't want pants to care about this binary when running
pants lint
since the binary will not be there. I could run
pants package
just before pants lint every time, similar to what i do with pants test, but I really don't want to do that (it seems bad to package something before its linted)
Are you adding the dependency to the python source target or the test target? What happens if you just add the dep to the source target?
Yes adding the package target as a dep worked! Thanks 🙂
FWIW if you're feeling technical you could make a plugin which exposes a resource target generator and use that as the explicit dependency. Then pants will invoke you're plugin to build the asset and put it in the sandbox when tests execute. This would eliminate the manual package step.
👍 1