Skip to content

Commit

Permalink
Merge pull request #114 from NoahTheDuke/watchexec
Browse files Browse the repository at this point in the history
Switch from `cargo-watch` to `watchexec-cli`
  • Loading branch information
laniakea64 authored Nov 5, 2024
2 parents c11e414 + a6a82d6 commit d46aeb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ is a simple test-runner in the `main` fn.
* Rust ([simple/recommended installation instructions](https://www.rust-lang.org/tools/install); for detailed and alternative installation instructions see [here](https://forge.rust-lang.org/infra/other-installation-methods.html))

Run `just deps` to install the cargo dev dependencies, which right now is only
[`cargo-watch`](https://crates.io/crates/cargo-watch).
[Watchexec CLI](https://crates.io/crates/watchexec-cli).

### Running the tests

Expand Down Expand Up @@ -80,7 +80,7 @@ To run the filetype detection tests, run `just ftdetect` in tests/.
If you're going to do more than a simple change, I recommend calling `just watch` in tests/,
which will watch for any changes in the whole repo and re-run the test suite.
By default, it will run the syntax highlighting tests.
`just watch` accepts up to two parameters to customize which tests to watch:
`just watch` accepts positional parameters to customize which tests to watch:

```bash
# watch all syntax highlighting tests (default)
Expand Down
19 changes: 9 additions & 10 deletions tests/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ cases_invalid_justfiles := """
run FILTER='':
cargo run {{ if FILTER == '' { '' } else { '-- ' + quote(FILTER) } }}

watchwatch := '`just watch watch` is redundant'

# run tests whenever a file changes
watch RECIPE='run' FILTER='': build
cargo watch \
[positional-arguments]
watch *args:
{{if args =~ '(?:^|\s)watch(?:\s|$)' { error('`just watch watch` is redundant') } else { '' } }}
watchexec \
--clear \
--shell "{{quote(just_executable())}} \
{{if RECIPE == 'watch' { error(watchwatch) } else { quote(RECIPE) } }} \
{{if RECIPE + FILTER =~ 'watch' { error(watchwatch) } else if FILTER == '' { '' } else { quote(FILTER) } }} \
" \
--watch ..
--shell=none \
--project-origin {{quote(clean(source_directory() / '..'))}} \
--watch {{quote(clean(source_directory() / '..'))}} \
{{quote(just_executable())}} "$@"

# run ftdetect tests
ftdetect:
cargo run --bin=test-ftdetect

# install development dependencies
deps:
cargo install --locked cargo-watch
cargo install watchexec-cli

# compile test runner without running tests
build:
Expand Down

0 comments on commit d46aeb7

Please sign in to comment.