You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ENH: Add ForceOocAlgorithm flag to test both algorithm paths in in-core builds
DispatchAlgorithm now checks a static ForceOocAlgorithm() flag in addition
to array storage type. Tests use ForceOocAlgorithmGuard with Catch2 GENERATE
to exercise both BFS and CCL paths regardless of build configuration.
Signed-off-by: Joey Kleingers <[email protected]>
Checks whether any array in `arrays` uses OOC storage. If so, constructs `OocAlgo(args...)` and calls `operator()()`. Otherwise, constructs `InCoreAlgo(args...)` and calls `operator()()`.
82
+
Checks whether any array in `arrays` uses OOC storage, or if the global `ForceOocAlgorithm()` flag is set. If either condition is true, constructs `OocAlgo(args...)` and calls `operator()()`. Otherwise, constructs `InCoreAlgo(args...)` and calls `operator()()`.
83
83
84
84
**Requirements for algorithm classes:**
85
85
@@ -166,7 +166,48 @@ Filters/Algorithms/
166
166
167
167
5. **Register new files**: Add the new algorithm names to the plugin's `AlgorithmList` in `CMakeLists.txt`.
168
168
169
-
6. **Test both paths**: Run the filter's tests with both in-core and OOC configurations. Both must produce identical results.
169
+
6. **Test both paths**: Use `ForceOocAlgorithmGuard` with Catch2 `GENERATE` to exercise both algorithm paths in every build configuration (see below).
170
+
171
+
## Testing Both Algorithm Paths
172
+
173
+
CI typically only builds the in-core configuration, so the OOC algorithm path would never be exercised without an explicit override. The `ForceOocAlgorithm()` flag and `ForceOocAlgorithmGuard` RAII class solve this.
174
+
175
+
### ForceOocAlgorithm
176
+
177
+
```cpp
178
+
bool& ForceOocAlgorithm();
179
+
```
180
+
181
+
Returns a reference to a static bool. When set to `true`, `DispatchAlgorithm` always selects the OOC algorithm class regardless of whether the data arrays use chunked storage. Defaults to `false`.
182
+
183
+
### ForceOocAlgorithmGuard
184
+
185
+
```cpp
186
+
classForceOocAlgorithmGuard
187
+
{
188
+
public:
189
+
ForceOocAlgorithmGuard(bool force);
190
+
~ForceOocAlgorithmGuard();
191
+
// non-copyable, non-movable
192
+
};
193
+
```
194
+
195
+
RAII guard that sets `ForceOocAlgorithm()` on construction and restores the previous value on destruction. Use with Catch2 `GENERATE` to run each test case twice — once with the in-core algorithm and once with the OOC algorithm:
// ... test body runs identically for both algorithm paths ...
207
+
}
208
+
```
209
+
210
+
This ensures both code paths are tested in every build configuration (in-core and OOC). The OOC algorithm class works correctly on in-core `DataStore` data because the chunk API methods are no-ops for `DataStore` (1 chunk spanning the full volume).
0 commit comments