ReviewOS

also looking at this

zig-utils/zig-test-framework

feat: load strict JSON configuration files

#19
Merged glennmichael123 wants to merge codex/issue-12-config into main
10 files +249 -286

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

FEATURES_SUMMARY.mdmodified+3-5
Changes to FEATURES_SUMMARY.md
@@ -258,12 +258,10 @@ This document provides a comprehensive overview of all implemented features in t
258258- **Status:** Production Ready
259259- **Module:** `src/config.zig`
260260- **Features:**
261 - YAML configuration support
262 - JSON configuration support
263 - TOML configuration support
264 - Configuration validation
261 - Strict JSON configuration support
262 - Unknown-key, type, and runtime-value validation
263 - CLI-over-config precedence
265264 - Default configuration
266 - Environment-specific configs
267265
268266### 16. Test History ✅
269267
README.mdmodified+31-4
Changes to README.md
@@ -24,7 +24,7 @@ A modern, feature-rich testing framework for Zig inspired by Jest, Vitest, and B
2424- **Watch Mode** - Automatically re-run tests on file changes
2525- **Memory Profiling** - Track memory usage and detect leaks
2626- **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
2828
2929## Installation
3030
@@ -100,8 +100,8 @@ This will automatically discover and run all `*.test.zig` files in the `tests` d
100100
101101Discovery mode rejects options that it cannot honor yet instead of silently
102102ignoring them. Reporter selection, quiet output, timeouts, parallel jobs,
103snapshot updates, memory profiling, configuration files, JUnit output, and the
104web UI require the shared execution pipeline planned for future releases.
103snapshot updates, memory profiling, JUnit output, and the web UI require the
104shared execution pipeline planned for future releases.
105105
106106**Examples:**
107107
@@ -119,6 +119,33 @@ zig-test --test-dir tests --no-recursive
119119zig-test --test-dir tests --bail
120120```
121121
122### Configuration files
123
124`--config <file>` loads a strict JSON configuration before test discovery.
125Unknown keys, duplicate keys, wrong value types, unsupported extensions, and
126invalid runtime values fail with a configuration error. TOML and YAML are not
127currently supported. Explicit CLI options are parsed after the file and take
128precedence 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
145The accepted top-level sections are `test`, `parallel`, `reporter`, `snapshot`,
146`watch`, `memory`, `ui`, and `coverage`. Options retain the same execution-mode
147limitations as their CLI equivalents; unsupported combinations fail explicitly.
148
122149### Programmatic Mode
123150
124151For more control, you can manually register tests:
@@ -824,7 +851,7 @@ MIT License - see [LICENSE](LICENSE) for details.
824851- [x] Watch mode for file changes
825852- [x] TAP/JUnit reporters
826853- [x] Memory profiling
827- [x] Configuration files (YAML/JSON/TOML)
854- [x] Strict JSON configuration files
828855- [x] Parallel test execution
829856- [ ] Parameterized tests (it.each)
830857- [ ] Property-based testing
build.zigmodified+16-0
Changes to build.zig
@@ -242,6 +242,22 @@ pub fn build(b: *std.Build) void {
242242 test_step.dependOn(&run_snapshot_usage_tests.step);
243243 test_step.dependOn(&run_time_tests.step);
244244
245 // Exercise configuration through the real CLI. The second invocation
246 // proves that an explicit CLI filter overrides the configured filter.
247 const run_config_fixture = b.addRunArtifact(exe);
248 run_config_fixture.addArgs(&.{ "--config", "tests/fixtures/zig-test.json" });
249 test_step.dependOn(&run_config_fixture.step);
250
251 const run_config_override = b.addRunArtifact(exe);
252 run_config_override.addArgs(&.{ "--config", "tests/fixtures/zig-test.json", "--filter", "unselected test fails" });
253 run_config_override.expectExitCode(1);
254 test_step.dependOn(&run_config_override.step);
255
256 const run_invalid_config = b.addRunArtifact(exe);
257 run_invalid_config.addArgs(&.{ "--config", "tests/fixtures/invalid-zig-test.json" });
258 run_invalid_config.expectExitCode(2);
259 test_step.dependOn(&run_invalid_config.step);
260
245261 // Examples
246262 const basic_example = b.addExecutable(.{
247263 .name = "basic_example",