Allow junit tests to have empty sources
Review Request #2923 - Created Oct. 2, 2015 and submitted
Adds an advanced option
--test-junit-allow-empty-sourcesto allow a BUILD file to contain a test target that defines empty sources.
This is a convenience for us with out BUILD file in a maven style layout. Our test targets are defined with a regular pattern,junit_tests(name='test', sources = rglobs('*Test.java'), ... ) junit_tests(name='integration-tests', sources = rglobs('*IT.java'), ... ) java_library(name='lib', sources = rglobs('*.java') - rglobs('*IT.java') - rglobs('*Test.java'), ... )
And our scripts expect to be able to run
./pants test <project>:teston any project
but some directories are missing some classes of tests. Without this change, our BUILD file generation has to search the filesystem to find if tests with particular glob patterns exist and re-write these 'junit_tests()' targets with
target(), which slows things down.
Rebase before merge
Revision 2 (+21 -5)
Status: Closed (submitted)
Thanks Garrett. Went ahead and merged it, but if there are objections I'm happy to reconsider. Commit 8f137c6
And our scripts expect to be able to run ./pants test <project>:test on any project
We strongly recommend
./pants test <project>::internally. It ensures that all code (not just code which happens to have tests) is built. And generally, it would be good to move further in the direction of requiring non-empty targets.