also looking at this
feat: load strict JSON configuration files
#19
10 files
+249
-286
| @@ -24,7 +24,7 @@ A modern, feature-rich testing framework for Zig inspired by Jest, Vitest, and B | ||
| 24 | 24 | - **Watch Mode** - Automatically re-run tests on file changes |
| 25 | 25 | - **Memory Profiling** - Track memory usage and detect leaks |
| 26 | 26 | - **Parallel Execution** - Run tests in parallel for faster execution |
| 27 | - **Configuration Files** - YAML/JSON/TOML config file support | |
| 27 | - **Configuration Files** - Strict JSON config files with CLI overrides | |
| 28 | 28 | |
| 29 | 29 | ## Installation |
| 30 | 30 | |
| @@ -100,8 +100,8 @@ This will automatically discover and run all `*.test.zig` files in the `tests` d | ||
| 100 | 100 | |
| 101 | 101 | Discovery mode rejects options that it cannot honor yet instead of silently |
| 102 | 102 | ignoring them. Reporter selection, quiet output, timeouts, parallel jobs, |
| 103 | snapshot updates, memory profiling, configuration files, JUnit output, and the | |
| 104 | web UI require the shared execution pipeline planned for future releases. | |
| 103 | snapshot updates, memory profiling, JUnit output, and the web UI require the | |
| 104 | shared execution pipeline planned for future releases. | |
| 105 | 105 | |
| 106 | 106 | **Examples:** |
| 107 | 107 | |
| @@ -119,6 +119,33 @@ zig-test --test-dir tests --no-recursive | ||
| 119 | 119 | zig-test --test-dir tests --bail |
| 120 | 120 | ``` |
| 121 | 121 | |
| 122 | ### Configuration files | |
| 123 | ||
| 124 | `--config <file>` loads a strict JSON configuration before test discovery. | |
| 125 | Unknown keys, duplicate keys, wrong value types, unsupported extensions, and | |
| 126 | invalid runtime values fail with a configuration error. TOML and YAML are not | |
| 127 | currently supported. Explicit CLI options are parsed after the file and take | |
| 128 | precedence over configured values. | |
| 129 | ||
| 130 | ```json | |
| 131 | { | |
| 132 | "test": { | |
| 133 | "test_dir": "tests", | |
| 134 | "pattern": "*.test.zig", | |
| 135 | "recursive": true, | |
| 136 | "filter": "database" | |
| 137 | }, | |
| 138 | "coverage": { | |
| 139 | "enabled": false, | |
| 140 | "output_dir": "coverage" | |
| 141 | } | |
| 142 | } | |
| 143 | ``` | |
| 144 | ||
| 145 | The accepted top-level sections are `test`, `parallel`, `reporter`, `snapshot`, | |
| 146 | `watch`, `memory`, `ui`, and `coverage`. Options retain the same execution-mode | |
| 147 | limitations as their CLI equivalents; unsupported combinations fail explicitly. | |
| 148 | ||
| 122 | 149 | ### Programmatic Mode |
| 123 | 150 | |
| 124 | 151 | For more control, you can manually register tests: |
| @@ -824,7 +851,7 @@ MIT License - see [LICENSE](LICENSE) for details. | ||
| 824 | 851 | - [x] Watch mode for file changes |
| 825 | 852 | - [x] TAP/JUnit reporters |
| 826 | 853 | - [x] Memory profiling |
| 827 | - [x] Configuration files (YAML/JSON/TOML) | |
| 854 | - [x] Strict JSON configuration files | |
| 828 | 855 | - [x] Parallel test execution |
| 829 | 856 | - [ ] Parameterized tests (it.each) |
| 830 | 857 | - [ ] Property-based testing |