hey all, I’m trying to find a way to run all tests...
# general
c
hey all, I’m trying to find a way to run all tests that stem from a given docker image (aka a given pex_binary). Right now, I’m able to list all the python sources by doing something like this:
Copy code
/pants dependencies --transitive src/docker/app_name:docker
but that doesn’t give me any test targets. I’m not sure how to pipe that into something that would also give me all tests that depend on the targets above. any ideas on how i could fix?
h
You're close
Here's how I did it
Sorry, this is php because of the tool it's written it
Copy code
$pants = "{$this->projectRoot}/./pants";
$cmd = "{$pants} --changed-since={$upstream} --changed-dependees=direct list";
$cmd = $cmd . " | xargs {$pants} dependees list | xargs {$pants} --colors test";
Basically, pipe the result of your transitive dependencies into
test
using
| xargs
test
will only run on the targets that have a test defined
The extra business in my example is if you don't want to run all the tests and instead just want the first couple levels as more of a smoke test.
c
oh sorry
yeah so my issue is that when I do
./pants dependencies --transitive src/docker/app_name:docker
I don’t see any test targets
h
Notice also the
dependees
call out which gets you the
test
targets back
c
ohh
hmm
h
So something like
dependencies | xargs dependees --transitive list | xrags test
in some pseudo code
c
yeah ok
that makes sense
that’s funky
but it works 🤷‍♂️
h
Agreed on the funkiness. When I first asked about this/developed the workaround, it seemed like there was some favor for putting behavior like this in the tool directly. Your example is a cool derivative of my original intent.