The documentation around the --include and --exclude flags of buck test are a bit confusing and doesn't seem to match up with how it works in practice. I'm not sure if the documentation is out of date and the behaviour is correct or whether this is a genuine bug in the behaviour of these flags.
Expected behaviour: Using --include and --exclude in conjunction applies both filters
Actual behaviour: Using --include and --exclude in conjunction ignores --excludeSteps to reproduce: Run buck test --all --include fast --exclude fast+unstable
The documentation around buck test provides the following example of using the --include and --exclude flags:
--include Test labels to run with this test. Labels are a way to group together tests of a particular type and run them together. For example, a developer could mark all tests that run in less than 100 milliseconds with the fast label, and then use:
buck test --all --include fast
to run only fast tests. See java_test() for more details.
Use multiple arguments to match any label, and + to match a set of labels. For example to match all the fast tests that are either stable or trustworthy, and aren't unstable:
The later example implies that both --include and --exclude can be used together, although the example itself is questionable as (presumably) the included labels (fast+stable, fast+trustworthy) will never overlap with the excluded label (fast+unstable)?
This is all very confusing and not intuitive. In a small example project it might not seem particularly relevant, but in a large code base it would be convenient to have a broad category of tests (e.g. 'fast') and then a subset of those that may not need to be run every time (e.g. 'intermittent') and having to specify an extra label to do the inverse (e.g. 'fast+reliable') rather than just --excludeing the subset (e.g. 'fast+intermittent') tests seems cumbersome?
The documentation around the
--include
and--exclude
flags ofbuck test
are a bit confusing and doesn't seem to match up with how it works in practice. I'm not sure if the documentation is out of date and the behaviour is correct or whether this is a genuine bug in the behaviour of these flags.Expected behaviour: Using
--include
and--exclude
in conjunction applies both filters Actual behaviour: Using--include
and--exclude
in conjunction ignores--exclude
Steps to reproduce: Runbuck test --all --include fast --exclude fast+unstable
The documentation around
buck test
provides the following example of using the--include
and--exclude
flags:The later example implies that both
--include
and--exclude
can be used together, although the example itself is questionable as (presumably) the included labels (fast+stable
,fast+trustworthy
) will never overlap with the excluded label (fast+unstable
)?For example, given four build rules:
... running
buck test --all
would run all four:... and likewise running
buck test --all --include 'fast'
runs the three fast tests:... and running
buck test --all --exclude 'unstable'
runs the three non-failing tests:... but running
buck test --all --include 'fast' --exclude 'unstable'
runs all three fast tests rather than just two (as I would expect):Weirdly, the order of the
--include
and--exclude
flags appears to have an effect, because swapping them around produces a different result:This is all very confusing and not intuitive. In a small example project it might not seem particularly relevant, but in a large code base it would be convenient to have a broad category of tests (e.g. 'fast') and then a subset of those that may not need to be run every time (e.g. 'intermittent') and having to specify an extra label to do the inverse (e.g. 'fast+reliable') rather than just
--exclude
ing the subset (e.g. 'fast+intermittent') tests seems cumbersome?(example: https://github.com/swarren12/buck-test-labels-example)