Does pants have a built-in or recommended way to v...
# general
s
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
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
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
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
./pants --owner-of=“$file” list
(This is deprecated. Use
./pants list $file
)
a
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
Thanks!
a
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