pants: `overrides` field does not work properly with tag exclusion
Describe the bug
Assume src/python/foo containing test_a.py and test_b.py, with this target in src/python/foo/BUILD:
python_tests(
name="tests",
overrides={
"test_a.py": {"tags": ["xyz"]},
}
)
./pants test src/python/foo/:: runs both tests, of course, as expected.
./pants --tag=xyz src/python/foo/:: runs just test_a.py, as expected.
However
./pants --tag=-xyz src/python/foo/:: runs both tests, whereas the user would expect it to run only test_b.py.
The reason is that --tag=-xyz src/python/foo/:: expands to [src/python/foo:tests, src/python/foo/test_b.py:tests] - the generator target does not have the tag so it is not excluded.
Then, the test goal expands to all dependencies, and since the generator src/python/foo:tests depends on src/python/foo/test_a.py:tests, that target gets pulled back into the working set.
Pants version 2.12.0.dev0 at least
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (12 by maintainers)
Commits related to this issue
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (#15394) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pantsbuild/pants/issues/111... — committed to pantsbuild/pants by Eric-Arellano 2 years ago
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (#15394) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pantsbuild/pants/issues/111... — committed to Eric-Arellano/pants by Eric-Arellano 2 years ago
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (#15394) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pantsbuild/pants/issues/111... — committed to stuhood/pants by Eric-Arellano 2 years ago
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (#15394) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pantsbuild/pants/issues/111... — committed to stuhood/pants by Eric-Arellano 2 years ago
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (Cherry-pick of #15394) (#15413) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pan... — committed to pantsbuild/pants by stuhood 2 years ago
- Fix `tags` to work with filesystem arguments, `overrides` field, and `python_tests` (Cherry-pick of #15394) (#15412) Closes https://github.com/pantsbuild/pants/issues/14977 and https://github.com/pan... — committed to pantsbuild/pants by stuhood 2 years ago
I want to work on this! Can it be assigned to me?
I’m seeing related(?) behavior using pants 2.10.0. We have the equivalent of:
(We tag both “ci” and “skip_ci” because we’re incrementally migrating onto pants, and explicitly marking both known-to-work and known-to-not-work tests so we know anything without a label is still TODO).
I tried all of these filter combinations in an attempt to test everything except
test_a.py, but nothing worked:All 3
--tagvalues do what I’d expect when I use./pants filterThat wouldn’t address the issue in this case: this is in the presence of
overrides, so the tag does not exist on the alias.