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

stale-insurance-57290

02/24/2020, 4:10 PM
Does pants have a built-in or recommended way to validate that all tests actually run when
./pants test [...]
is invoked? Both 1. file name pattern matching to validate that all files are included in (e.g.) a
junit_tests
target and 2. checking that all (e.g.)
junit_tests
targets are reachable from some target would be useful
a

aloof-angle-91616

02/24/2020, 4:18 PM
so one thing you can do for (1) is:
Copy code
> find tests/ -type f | while read -r file; do
  lines="$(./pants --owner-of="$file" list | wc -l)"
  if [[ "$lines" -ge 1 ]]; then
    echo "found target for $file"
  else
    echo "did not find target for $file"
    exit 1
  fi
done
for (2), what do you mean by reachable? pants has
./pants dependencies
as well as
./pants dependees
s

stale-insurance-57290

02/24/2020, 4:23 PM
In (2), the question I want to answer is: If I run
./pants test $TARGET
, are there any (e.g.)
junit_tests
targets in the directory containing
$TARGET
or any of its subdirectories that won't get run
Possibly excluding or only including certain target names
a

aloof-angle-91616

02/24/2020, 4:26 PM
so if you're looking to just make sure everything is run within a subdirectory (not sure if that's the idea), you can do
./pants path/to/target/dir::
and if you want to exclude certain target names, you can use the
filter
task, which stil requires a separate pants invocation
h

hundreds-father-404

02/24/2020, 4:27 PM
./pants --owner-of=“$file” list
(This is deprecated. Use
./pants list $file
)
a

aloof-angle-91616

02/24/2020, 4:28 PM
i didn't know what version of pants they were on, didn't want to give them a command line that didn't work, and assumed the deprecation warning would point them to the correct behavior
👍 1
s

stale-insurance-57290

02/24/2020, 4:29 PM
Thanks!
a

aloof-angle-91616

02/24/2020, 4:29 PM
if the
--query
option in those PRs would be useful for you please feel free to weigh in on functionality you might find useful in https://github.com/pantsbuild/pants/pull/7356
3 Views