From d375ccc8c456c1f0924da8fdf2cd68ee6c21be73 Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Fri, 29 Dec 2023 19:54:27 -0500 Subject: [PATCH 1/2] tests: improved and more flexible `just watch`: - compile test runner before watching - run user-specified tests justfile recipe instead of hard-coded cargo command - quote parameters --- tests/justfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/justfile b/tests/justfile index e44a4c0..594fb97 100644 --- a/tests/justfile +++ b/tests/justfile @@ -5,12 +5,16 @@ set fallback run FILTER='': cargo run {{ if FILTER == '' { '' } else { '-- ' + quote(FILTER) } }} +watchwatch := '`just watch watch` is redundant' + # run tests whenever a file changes -watch FILTER='': +watch RECIPE='run' FILTER='': build cargo watch \ --clear \ - --debug \ - --exec "run {{FILTER}}" \ + --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 .. # run ftdetect tests From a20e2a3bc30cdb37a6902e33186fdcb7e56444fe Mon Sep 17 00:00:00 2001 From: laniakea64 Date: Tue, 26 Dec 2023 09:40:42 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 819ed47..8ba5b85 100644 --- a/README.md +++ b/README.md @@ -76,9 +76,55 @@ Run `just deps` to install the cargo dev dependencies, which right now is only ### Test Suite -To run the tests, run `just run` in tests/. Cargo will build and run the project, which -is a simple test-runner in the `main` fn. 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. If you want to only run or watch a single test file, you -can specify the name by passing an argument to `run` or `watch`: `just run -recipe-dependency`. +`vim-just` includes automated tests of its syntax highlighting and filetype detection. +Running the tests invokes Cargo to build and run the project, which +is a simple test-runner in the `main` fn. + +To run the syntax highlighting tests, run `just run` in tests/. +If you want to run only a subset of the syntax highlighting tests, +you can pass an optional regex parameter to `just run` matching the filenames you want to include: + +```bash +# run only the 'kitchen-sink.just' syntax highlighting test +$ just run kitchen-sink +... +test kitchen-sink… +ok + +# run the syntax highlighting tests with base filenames matching the regex ^\w+$ +$ just run '^\w+$' +... +test comment… +ok +test deprecated_obsolete… +ok +test invalid… +ok +test set… +ok +test tricky… +ok +``` + +Note that the `.just` extension is trimmed off before matching against the regex. + +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: + +```bash +# watch all syntax highlighting tests (default) +$ just watch + +# watch ftdetect tests +$ just watch ftdetect + +# watch all tests +$ just watch ftdetect run + +# watch syntax highlighting tests with filenames matching the regex ^r.*s$ +$ just watch run '^r.*s$' +```