|
| 1 | +--- |
| 2 | +date: '2026-03-17' |
| 3 | +title: 'Release 0.34.0' |
| 4 | +description: 'Watch mode, test tags, date/JSON/duration assertions, and major performance gains.' |
| 5 | +coverAlt: 'Watch mode, test tags, new assertions, performance optimizations' |
| 6 | + |
| 7 | +aside: false |
| 8 | +--- |
| 9 | + |
| 10 | +# {{ $frontmatter.title }} |
| 11 | + |
| 12 | +<time>{{ $formatDate($frontmatter.date) }}</time> |
| 13 | + |
| 14 | +## 🔧 New features |
| 15 | + |
| 16 | +### Watch mode |
| 17 | + |
| 18 | +Automatically re-run tests whenever source files change. Uses `inotifywait` on Linux or `fswatch` on macOS: |
| 19 | + |
| 20 | +::: code-group |
| 21 | +```bash [Usage] |
| 22 | +bashunit watch tests/ |
| 23 | +# or as a flag |
| 24 | +bashunit --watch tests/ |
| 25 | +``` |
| 26 | +::: |
| 27 | + |
| 28 | +If the required file-watching tool is not installed, bashunit provides a clear installation hint. |
| 29 | + |
| 30 | +### Test tags |
| 31 | + |
| 32 | +Filter tests by `# @tag` annotations using `--tag` and `--exclude-tag`: |
| 33 | + |
| 34 | +::: code-group |
| 35 | +```bash [Annotate tests] |
| 36 | +# @tag slow |
| 37 | +function test_heavy_computation() { |
| 38 | + ... |
| 39 | +} |
| 40 | + |
| 41 | +# @tag integration |
| 42 | +function test_api_call() { |
| 43 | + ... |
| 44 | +} |
| 45 | +``` |
| 46 | +```bash [Run by tag] |
| 47 | +bashunit --tag slow tests/ |
| 48 | +bashunit --exclude-tag integration tests/ |
| 49 | +``` |
| 50 | +::: |
| 51 | + |
| 52 | +### Date comparison assertions |
| 53 | + |
| 54 | +A full suite of date assertions with automatic format detection (epoch seconds, ISO 8601, space-separated datetime, and timezone offsets): |
| 55 | + |
| 56 | +- `assert_date_equals` - two dates represent the same point in time |
| 57 | +- `assert_date_before` / `assert_date_after` - chronological ordering |
| 58 | +- `assert_date_within_range` - date falls between two bounds |
| 59 | +- `assert_date_within_delta` - date is within N seconds of a reference |
| 60 | + |
| 61 | +### JSON assertions |
| 62 | + |
| 63 | +Validate JSON output using `jq` under the hood: |
| 64 | + |
| 65 | +- `assert_json_key_exists` - a key is present in the JSON |
| 66 | +- `assert_json_contains` - JSON contains a key-value pair |
| 67 | +- `assert_json_equals` - full JSON equality check |
| 68 | + |
| 69 | +### Duration assertions |
| 70 | + |
| 71 | +Measure how long a function takes to execute: |
| 72 | + |
| 73 | +- `assert_duration` - execution finishes in exactly N seconds |
| 74 | +- `assert_duration_less_than` - execution finishes under N seconds |
| 75 | +- `assert_duration_greater_than` - execution takes at least N seconds |
| 76 | + |
| 77 | +### More assertion power |
| 78 | + |
| 79 | +- `assert_have_been_called_nth_with` - verify spy arguments on a specific invocation |
| 80 | +- `assert_string_matches_format` / `assert_string_not_matches_format` - match strings against format placeholders (`%d`, `%s`, `%f`, `%i`, `%x`, `%e`, `%%`) |
| 81 | +- TAP version 13 output format via `--output tap` for CI/CD integration |
| 82 | +- `--jobs N` flag to limit parallel test concurrency |
| 83 | +- Source context display in failure summaries showing the relevant assertion lines |
| 84 | + |
| 85 | +## ⚡ Performance |
| 86 | + |
| 87 | +This release includes significant performance optimizations reducing subprocess overhead across the board: |
| 88 | + |
| 89 | +- Cache function discovery to avoid duplicate pipelines per test file |
| 90 | +- Reduce subshells in the test execution hot path |
| 91 | +- Batch coverage recording with in-memory buffering |
| 92 | +- Cache `uname` result at source time to eliminate repeated subprocess forks |
| 93 | +- Replace `bc` and `awk` subprocesses with native bash arithmetic in clock and duration formatting |
| 94 | +- Cache `base64 -w` flag support at load time instead of detecting per test |
| 95 | +- Use direct variable access for assertion state instead of getter subshells in the runner hot path |
| 96 | + |
| 97 | +## 🐛 Bug fixes |
| 98 | + |
| 99 | +- Fix misleading error message for `assert_not_same` and `assert_not_equals` on failure |
| 100 | +- Mocking `mktemp` no longer breaks spy creation |
| 101 | +- JUnit XML report now conforms to the standard schema |
| 102 | + - Proper `<failure>`/`<skipped>` child elements, `errors="0"` attribute |
| 103 | + - Convert `time` values from milliseconds to seconds (float) |
| 104 | + - Strip ANSI escape sequences and invalid XML control characters |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +See the full changelog on <a href="https://github.com/TypedDevs/bashunit/releases/tag/0.34.0">GitHub</a> |
0 commit comments