Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using watchfiles to run two commands with "&&" #315

Open
hugovk opened this issue Dec 2, 2024 · 1 comment
Open

Using watchfiles to run two commands with "&&" #315

hugovk opened this issue Dec 2, 2024 · 1 comment

Comments

@hugovk
Copy link
Contributor

hugovk commented Dec 2, 2024

I'd like to use watchfiles for Advent of Code.

When run with pytest, the Python runs unit tests on the short example. And when run with the Python interpreter, runs against the full input.

For example, I run:

pytest part1.py && python3 part1.py
  • When the unit tests aren't working yet, only the quick unit tests run with pytest.
  • Then when the tests pass, it next runs the interpreter on the full, slow input.

I'd like to do something like:

watchfiles "pytest part1.py && python3 part1.py"

But it passes the whole thing to pytest which errors with "ERROR: file or directory not found: &&"

A workaround is to put pytest part1.py && python3 part1.py in a bash file and run:

watchfiles thing.sh

And I could create an alias, but would it be possible or sensible for watchfiles to handle it?


Operating System & Architecture:

macOS-14.7-arm64-arm-64bit-Mach-O
Darwin Kernel Version 23.6.0: Wed Jul 31 20:48:52 PDT 2024; root:xnu-10063.141.1.700.5~1/RELEASE_ARM64_T6020

Python & Watchfiles Version:

python: 3.13.0 (v3.13.0:60403a5409f, Oct  7 2024, 00:37:40) [Clang 15.0.0 (clang-1500.3.9.4)], watchfiles: 1.0.0
@samuelcolvin
Copy link
Owner

happy to accept a PR to support this, either special casing && or somehow running this with bash etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants