summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 10:01:03 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 10:01:03 +0100
commit9702ea06ced9585a705c41186f814700bc859dcd (patch)
treed45398e443d9b561991f820869e4f200d4d86ec0 /doc
parentdccbfe7f995db2e2bfe80fc611f6f053cafd9bb3 (diff)
test(gpu): Add automatic validation for effect test coverage
Problem: When new effects are added to demo_effects.h, developers might forget to update test_demo_effects.cc, leading to untested code. Solution: Added compile-time constants and runtime assertions to enforce test coverage: 1. Added EXPECTED_POST_PROCESS_COUNT = 8 2. Added EXPECTED_SCENE_COUNT = 6 3. Runtime validation in each test function 4. Fails with clear error message if counts don't match Error message when validation fails: ✗ COVERAGE ERROR: Expected N effects, but only tested M! ✗ Did you add a new effect without updating the test? ✗ Update EXPECTED_*_COUNT in test_demo_effects.cc Updated CONTRIBUTING.md with mandatory test update requirement: - Added step 3 to "Adding a New Visual Effect" workflow - Clear instructions on updating effect counts - Verification command examples This ensures no effect can be added without corresponding test coverage. Tested validation by intentionally breaking count - error caught correctly.
Diffstat (limited to 'doc')
-rw-r--r--doc/CONTRIBUTING.md13
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/CONTRIBUTING.md b/doc/CONTRIBUTING.md
index 4b85e9f..7d206a5 100644
--- a/doc/CONTRIBUTING.md
+++ b/doc/CONTRIBUTING.md
@@ -255,7 +255,18 @@ Make sure everything is reflected in clang-format.
- Implement `compute()` if you need GPU-side physics or state updates.
- Implement `render()` to record WebGPU draw commands.
2. **Register**: Add an `EFFECT` entry to `assets/demo.seq` specifying the class name, start/end times, and any constructor arguments.
-3. **Verify**: Build with `DEMO_ALL_OPTIONS=ON` and use `--seek` to test your effect at its specific timestamp.
+3. **Update Tests** (REQUIRED): Add your effect to `src/tests/test_demo_effects.cc`:
+ - Add effect to the appropriate test list (`test_post_process_effects()` or `test_scene_effects()`)
+ - Increment `EXPECTED_POST_PROCESS_COUNT` or `EXPECTED_SCENE_COUNT` at the top of the file
+ - If your effect requires `Renderer3D` with full shader setup, add it to the `requires_3d` check
+ - The test will fail with a clear error message if you forget this step
+4. **Verify**: Build with `DEMO_ALL_OPTIONS=ON` and run tests:
+ ```bash
+ cmake -S . -B build -DDEMO_BUILD_TESTS=ON
+ cmake --build build --target test_demo_effects
+ cd build && ./test_demo_effects
+ ```
+ Then test your effect at its specific timestamp with `--seek`.
### Audio Subsystem Initialization