77``` bash
88bashunit test [path] [options] # Run tests (default)
99bashunit bench [path] [options] # Run benchmarks
10+ bashunit watch [path] [options] # Watch files, re-run tests on change
11+ bashunit assert < fn> < args> # Run standalone assertion
1012bashunit doc [filter] # Show assertion documentation
1113bashunit init [dir] # Initialize test directory
1214bashunit learn # Interactive tutorial
@@ -55,6 +57,10 @@ bashunit test tests/ --parallel --simple
5557| ` -a, --assert <fn> <args> ` | Run a standalone assert function |
5658| ` -e, --env, --boot <file> ` | Load custom env/bootstrap file (supports args) |
5759| ` -f, --filter <name> ` | Only run tests matching name |
60+ | ` --tag <name> ` | Only run tests with matching ` @tag ` (repeatable) |
61+ | ` --exclude-tag <name> ` | Skip tests with matching ` @tag ` (repeatable) |
62+ | ` --output <format> ` | Output format (` tap ` for TAP version 13) |
63+ | ` -w, --watch ` | Watch files and re-run tests on change |
5864| ` --log-junit <file> ` | Write JUnit XML report |
5965| ` -j, --jobs <N> ` | Run tests in parallel with max N concurrent jobs |
6066| ` -p, --parallel ` | Run tests in parallel |
@@ -114,6 +120,84 @@ bashunit test tests/ --filter "user_login"
114120```
115121:::
116122
123+ ### Tags
124+
125+ > ` bashunit test --tag <name> `
126+ > ` bashunit test --exclude-tag <name> `
127+
128+ Filter tests by ` # @tag ` annotations. Both flags are repeatable. ` --tag ` uses OR
129+ logic across names; ` --exclude-tag ` wins when a test matches both.
130+
131+ ::: code-group
132+ ``` bash [Annotate tests]
133+ # @tag slow
134+ function test_heavy_computation() {
135+ ...
136+ }
137+
138+ # @tag integration
139+ function test_api_call() {
140+ ...
141+ }
142+ ```
143+ ``` bash [Run by tag]
144+ bashunit test tests/ --tag slow
145+ bashunit test tests/ --tag slow --tag integration
146+ bashunit test tests/ --exclude-tag integration
147+ ```
148+ :::
149+
150+ ### Output format
151+
152+ > ` bashunit test --output <format> `
153+
154+ Select an alternative output format. Currently supported:
155+
156+ - ` tap ` — [ TAP version 13] ( https://testanything.org/tap-version-13-specification.html ) for CI/CD integrations.
157+
158+ The ` TAP version 13 ` header comes first, each test file is announced via a
159+ ` # <path> ` diagnostic line, each test emits an ` ok <n> - <name> ` or
160+ ` not ok <n> - <name> ` line (failures include a YAML ` --- ... ... ` block with
161+ expected/actual), and the ` 1..N ` plan line closes the report.
162+
163+ ::: code-group
164+ ``` bash [Example]
165+ bashunit test tests/ --output tap
166+ ```
167+ ``` [Output]
168+ TAP version 13
169+ # tests/example_test.sh
170+ ok 1 - Should validate input
171+ not ok 2 - Should handle errors
172+ ---
173+ Expected 'foo'
174+ but got 'bar'
175+ ...
176+
177+ 1..2
178+ ```
179+ :::
180+
181+ ### Watch mode
182+
183+ > ` bashunit test -w|--watch `
184+
185+ Watch the test path (plus ` src/ ` if present) and re-run tests when files change.
186+ The ` -w ` /` --watch ` flag uses a lightweight ** checksum polling loop** that works
187+ on any system — no external tools required.
188+
189+ ::: code-group
190+ ``` bash [Example]
191+ bashunit test tests/ --watch
192+ ```
193+ :::
194+
195+ ::: tip
196+ For file-event-driven watching (no polling), use the dedicated
197+ [ ` watch ` ] ( #watch ) subcommand, which relies on ` inotifywait ` (Linux) or
198+ ` fswatch ` (macOS).
199+ :::
200+
117201### Environment / Bootstrap
118202
119203> ` bashunit test -e|--env|--boot <file> `
@@ -326,7 +410,7 @@ This is useful for:
326410bashunit test tests/ --no-progress
327411```
328412``` [Output]
329- bashunit - 0.32.0 | Tests: 10
413+ bashunit - 0.34.1 | Tests: 10
330414Tests: 10 passed, 10 total
331415Assertions: 25 passed, 25 total
332416
@@ -464,6 +548,43 @@ bashunit bench --filter "parse"
464548| ` --skip-env-file ` | Skip ` .env ` loading, use shell environment only |
465549| ` -l, --login ` | Run in login shell context |
466550
551+ ## watch
552+
553+ > ` bashunit watch [path] [test-options] `
554+
555+ Dedicated watch subcommand that uses ** OS file-event notifications** (no
556+ polling) to re-run tests as soon as a ` .sh ` file changes. Any option accepted
557+ by ` bashunit test ` is also accepted here.
558+
559+ ::: code-group
560+ ``` bash [Examples]
561+ # Watch current directory
562+ bashunit watch
563+
564+ # Watch the tests/ directory
565+ bashunit watch tests/
566+
567+ # Watch and filter by name
568+ bashunit watch tests/ --filter user
569+
570+ # Watch with simple output
571+ bashunit watch tests/ --simple
572+ ```
573+ :::
574+
575+ ::: warning Requirements
576+ - ** Linux:** ` inotifywait ` (` sudo apt install inotify-tools ` )
577+ - ** macOS:** ` fswatch ` (` brew install fswatch ` )
578+
579+ If the required tool is not installed, bashunit prints a clear installation hint
580+ and exits with a non-zero code.
581+ :::
582+
583+ ::: tip
584+ If you cannot install ` inotifywait ` or ` fswatch ` , use the portable
585+ [ ` -w/--watch ` ] ( #watch-mode ) flag on ` bashunit test ` instead (uses polling).
586+ :::
587+
467588## doc
468589
469590> ` bashunit doc [filter] `
@@ -567,7 +688,7 @@ bashunit upgrade
567688```
568689``` [Output]
569690> Upgrading bashunit to latest version
570- > bashunit upgraded successfully to latest version 0.28.0
691+ > bashunit upgraded successfully to latest version 0.34.1
571692```
572693:::
573694
@@ -604,16 +725,18 @@ bashunit --help
604725Usage: bashunit <command> [arguments] [options]
605726
606727Commands:
607- test [path] Run tests (default command)
608- bench [path] Run benchmarks
609- doc [filter] Display assertion documentation
610- init [dir] Initialize a new test directory
611- learn Start interactive tutorial
612- upgrade Upgrade bashunit to latest version
728+ test [path] Run tests (default command)
729+ bench [path] Run benchmarks
730+ assert <fn> <args> Run standalone assertion
731+ doc [filter] Display assertion documentation
732+ init [dir] Initialize a new test directory
733+ learn Start interactive tutorial
734+ watch [path] Watch files and re-run tests on change
735+ upgrade Upgrade bashunit to latest version
613736
614737Global Options:
615- -h, --help Show this help message
616- -v, --version Display the current version
738+ -h, --help Show this help message
739+ -v, --version Display the current version
617740
618741Run 'bashunit <command> --help' for command-specific options.
619742```
@@ -624,6 +747,7 @@ Each subcommand also supports `--help`:
624747``` bash
625748bashunit test --help
626749bashunit bench --help
750+ bashunit watch --help
627751bashunit doc --help
628752```
629753
0 commit comments