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

thousands-plumber-33255

06/22/2022, 9:35 AM
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

curved-television-6568

06/22/2022, 9:41 AM
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

ambitious-actor-36781

06/22/2022, 9:46 AM
./pants --loop --changed-since=main --changed-dependees=transitive test fmt lint check
Changed my life. and it'll change yours too (maybe)
๐Ÿคฉ 2
๐Ÿ‘ 4
๐ŸŽ‰ 2
๐Ÿ”ฅ 2
f

fresh-cat-90827

06/22/2022, 10:22 AM
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

curved-television-6568

06/22/2022, 10:28 AM
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

ambitious-actor-36781

06/22/2022, 10:06 PM
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

thousands-plumber-33255

06/23/2022, 9:24 AM
Awesome, that helped a lot! ๐Ÿ˜Š
๐Ÿ‘ 1
h

hundreds-father-404

06/23/2022, 5:27 PM
@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
5 Views