diff options
| -rw-r--r-- | doc/CONTRIBUTING.md | 13 | ||||
| -rw-r--r-- | src/tests/test_demo_effects.cc | 30 |
2 files changed, 42 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 diff --git a/src/tests/test_demo_effects.cc b/src/tests/test_demo_effects.cc index c12345d..3292c9c 100644 --- a/src/tests/test_demo_effects.cc +++ b/src/tests/test_demo_effects.cc @@ -1,9 +1,19 @@ // This file is part of the 64k demo project. // It tests all demo effect classes for basic construction and initialization. // Validates that every effect can be instantiated and initialized without crashes. +// +// MAINTENANCE REQUIREMENT: When adding a new effect to demo_effects.h: +// 1. Add it to the appropriate test list (post_process_effects or scene_effects) +// 2. Update EXPECTED_POST_PROCESS_COUNT or EXPECTED_SCENE_COUNT below +// 3. Run test to verify: ./build/test_demo_effects +// 4. If the effect requires Renderer3D, add it to requires_3d check in test_scene_effects() #if !defined(STRIP_ALL) // Test code only - zero size impact on final binary +// Expected effect counts - UPDATE THESE when adding new effects! +static constexpr int EXPECTED_POST_PROCESS_COUNT = 8; // FlashEffect, PassthroughEffect, GaussianBlurEffect, ChromaAberrationEffect, DistortEffect, SolarizeEffect, FadeEffect, ThemeModulationEffect +static constexpr int EXPECTED_SCENE_COUNT = 6; // HeptagonEffect, ParticlesEffect, ParticleSprayEffect, MovingEllipseEffect, FlashCubeEffect, Hybrid3DEffect + #include "effect_test_helpers.h" #include "webgpu_test_fixture.h" #include "gpu/demo_effects.h" @@ -113,6 +123,16 @@ static void test_post_process_effects() { fprintf(stdout, " ✓ %d/%zu post-process effects tested\n", passed, effects.size()); + + // Validation: Ensure test coverage matches expected count + const int tested_count = static_cast<int>(effects.size()); + if (tested_count != EXPECTED_POST_PROCESS_COUNT) { + fprintf(stderr, " ✗ COVERAGE ERROR: Expected %d post-process effects, but only tested %d!\n", + EXPECTED_POST_PROCESS_COUNT, tested_count); + fprintf(stderr, " ✗ Did you add a new post-process effect without updating the test?\n"); + fprintf(stderr, " ✗ Update EXPECTED_POST_PROCESS_COUNT in test_demo_effects.cc\n"); + assert(false && "Post-process effect count mismatch - update test!"); + } } // Test 2: Scene effects @@ -171,6 +191,16 @@ static void test_scene_effects() { fprintf(stdout, " ✓ %d/%zu scene effects tested (%d skipped)\n", passed, effects.size(), skipped); + + // Validation: Ensure test coverage matches expected count + const int tested_count = static_cast<int>(effects.size()); + if (tested_count != EXPECTED_SCENE_COUNT) { + fprintf(stderr, " ✗ COVERAGE ERROR: Expected %d scene effects, but only tested %d!\n", + EXPECTED_SCENE_COUNT, tested_count); + fprintf(stderr, " ✗ Did you add a new scene effect without updating the test?\n"); + fprintf(stderr, " ✗ Update EXPECTED_SCENE_COUNT in test_demo_effects.cc\n"); + assert(false && "Scene effect count mismatch - update test!"); + } } // Test 3: Effect type classification |
