https://pantsbuild.org/ logo
#general
Title
# general
r

rapid-exabyte-76685

04/01/2022, 1:49 AM
To address some problems with certain tests not currently working under Pants vs the current environment (probably related to parallelism?) I tried defining two
python_tests
in the directory that has the tests in question... ๐Ÿงต
Copy code
python_tests(
  name="test",
  source=[
    "test_*.py",
    "!test_that_is_deadlocking1.py",
    "!test_that_is_deadlocking2.py"
  ]
)

python_tests(
  name="deadlocking_tests",
  source=[
    "test_that_is_deadlocking1.py",
    "test_that_is_deadlocking2.py"
  ]
)
If I run
./pants test ::
then both the non-deadlocking and deadlocking tests are run.
I think I'm expecting to be able to
./pants test ::tests
or something like that to only run all targets in the whole tree named
tests
but that doesn't seem to work.
But both
./pants test directory/where/the/build/file/is:tests
and
./pants test directory/where/the/build/file/is:deadlocking_tests
do include the correct tests
h

hundreds-father-404

04/01/2022, 1:53 AM
path/to/dir::
rather than
::path/to/dir
r

rapid-exabyte-76685

04/01/2022, 1:57 AM
If I run
./pants test test::
I'm still seeing
Copy code
Run Pytest for test/something/something/test_that_is_deadlocking1.py:deadlocking_tests
h

hundreds-father-404

04/01/2022, 2:01 AM
oh wait yeah that's expected -
test::
means all matching targets recursively under the dir
test
. If you want to run all those targets except for some, you could use tags https://www.pantsbuild.org/docs/advanced-target-selection#tags-annotating-targets (i also have a proposal to add ignore specs like
test:: !test/subdir::
)
r

rapid-exabyte-76685

04/01/2022, 2:10 AM
I'd like to use tags, but https://github.com/pantsbuild/pants/issues/14977 ๐Ÿ˜‰
I can progress with a
--spec-files
instead I think
w

witty-crayon-22786

04/01/2022, 3:23 AM
@rapid-exabyte-76685: fwiw, given that you have split into two generators like that, i think that tags should work fine. https://github.com/pantsbuild/pants/issues/14977 only affects
overrides
, afaict.
โœ… 1
r

rapid-exabyte-76685

04/01/2022, 3:36 AM
yep that does indeed work ๐Ÿ‘ much cleaner than a
--spec-file
๐Ÿ‘ 1