Hi everyone, we are currently adopting pants and r...
# general
t
Hi everyone, we are currently adopting pants and really enjoy using it even though there are plenty of questions left. I am looking forward to discuss interesting topics here. The first question I have is if there is some kind of "watch" mode for running tests. When unsing
./pants run
the command is watching the filesystem and restarts. Is there something similiar for
./pants test
? I know this from https://nx.dev/packages/jest/executors/jest#watch where you can enter watch mode with
yarn test myapp --watch
and then select a test based on a test name regex pattern (see attached screenshot). Is something like this available? If no watch mode is available, can I filter for a regex name and then select from a list of matches?
๐Ÿ‘‹ 2
c
Hi! Yes, you run like so:
./pants --loop test โ€ฆ
The
โ€ฆ
are the target
specs
for what you want to test. It can be file paths to your test sources, or target addresses etc. Thereโ€™s also a possilibity to filter targets based on tags etc.
a
./pants --loop --changed-since=main --changed-dependees=transitive test fmt lint check
Changed my life. and it'll change yours too (maybe)
๐Ÿคฉ 3
๐Ÿ‘ 4
๐ŸŽ‰ 2
๐Ÿ”ฅ 2
f
It is great that this feature exists, but imho how can you write code when what you write is being reformatted? Wouldnโ€™t it intervene with you making changes? I can imagine running tests once in a while, but constant reformatting? ๐Ÿ˜•
c
I could see that work, but I tend to only run tests in a loop while developing, then check in a loop while fixing type issues..
a
the goals will only run in sequence if the previous one has passed. So it's not too intrusive as it'll only be reformatted when the tests pass.
forces you to write your failing tests first, and then put the logic to fix it ๐Ÿ˜„
t
Awesome, that helped a lot! ๐Ÿ˜Š
๐Ÿ‘ 1
h
@ambitious-actor-36781 that would probably be nice to add to our docs, but I'm not sure where. My first thought is where we introduce `--loop`: https://www.pantsbuild.org/v2.13/docs/goals#running-goals Something short, like a one sentence example. (We don't want to be too distracting & noisy) Thoughts?
FYI our docs are now in-repo ๐ŸŽ‰ so you can preferably submit a PR to change e.g. https://github.com/pantsbuild/pants/blob/main/docs/markdown/Using%20Pants/concepts/goals.md, or you can still use "Suggest Edits" in the top right corner of Readme.com and a Pants maintainer will convert that to a PR for you