[lit] Better/earlier errors for empty runs
authorJulian Lettner <julian.lettner@apple.com>
Tue, 12 Nov 2019 16:24:26 +0000 (08:24 -0800)
committerJulian Lettner <julian.lettner@apple.com>
Tue, 12 Nov 2019 17:11:36 +0000 (09:11 -0800)
commit54a9b4c02ff57e9847e0c501578e51db6f73d3be
tree2d11119c5c50c1538e9ec639ed518861635d4bad
parent83dcb34b6bf4c175040b18d3e8c3c468418009fc
[lit] Better/earlier errors for empty runs

Fail early, when we discover no tests at all, or filter out all of them.

There is also `--allow-empty-runs` to disable test to allow workflows
like `LIT_FILTER=abc ninja check-all`.  Apparently `check-all` invokes
lit multiple times if certain projects are enabled, which would produce
unwanted "empty runs". Specify via `LIT_OPTS=--allow-empty-runs`.

There are 3 causes for empty runs:
1) No tests discovered.  This is always an error.  Fix test suite config
   or command line.
2) All tests filtered out.  This is an error by default, but can be
   suppressed via `--alow-empty-runs`.  Should prevent accidentally
   passing empty runs, but allow the workflow above.
3) The number of shards is greater than the number of tests.  Currently,
   this is never an error.  Personally, I think we should consider
   making this an error by default; if this happens, you are doing
   something wrong. I added a warning but did not change the behavior,
   since this warrants more discussion.

Reviewed By: atrick, jdenny

Differential Revision: https://reviews.llvm.org/D70105
llvm/utils/lit/lit/cl_arguments.py
llvm/utils/lit/lit/main.py
llvm/utils/lit/lit/run.py
llvm/utils/lit/tests/selecting.py