Commit 4260e06
authored
build(cmake): honor BUILD_TESTING and run simg4ox via ctest (#378)
This branch aligns Simphony's testing setup with standard CMake/CTest behavior and moves the existing `simg4ox` integration check under `ctest`.
The main goals are:
- respect `BUILD_TESTING` in the project tree
- make build-tree tests discoverable and runnable through `ctest`
- ensure external drivers such as Spack can enable tests and invoke `ctest` in a conventional way
- remove duplicated CI execution for `test_simg4ox.sh`
## Motivation
Before this change, test subdirectories were added unconditionally, which made the project less friendly to standard CMake testing flows and to package-manager driven builds.
In addition, `simg4ox` was validated via a standalone shell script instead of a registered CTest test. That meant CI and external tooling had to know about the script separately instead of relying on `ctest` as the single test entry point.
## What Changed
### Top-level CMake testing behavior
- define `BUILD_TESTING` using the standard CMake pattern
- default `BUILD_TESTING` to `PROJECT_IS_TOP_LEVEL`
- continue to `include(CTest)` even when `BUILD_TESTING=OFF`
- gate all `*/tests` subdirectories behind `if(BUILD_TESTING)`
This gives the expected behavior in both cases:
- top-level builds get tests by default
- subproject/package-manager builds do not force this project's tests on unless explicitly requested
Keeping `CTest` included even with `BUILD_TESTING=OFF` means external drivers can still run `ctest` and see an empty test set rather than missing test configuration.
### `simg4ox` CTest integration
- add a dedicated top-level [tests/CMakeLists.txt](tests/CMakeLists.txt) to register `Integration.simg4ox`
- run `simg4ox` from CTest using `$<TARGET_FILE:simg4ox>`
- use a fixed CTest working directory created from CMake
- keep the wrapper script minimal and focused on launching the executable and comparison step
This turns the existing `tests/test_simg4ox.sh` flow into a normal CTest integration test instead of an external ad hoc command.
### A/B comparison script cleanup
- move the old `tests/compare_ab.py` to [optiphy/ana/compare_ab.py](optiphy/ana/compare_ab.py)
- remove the old `tests/compare_ab.py`
- keep the script serving the same core purpose: compare A/B event outputs and validate the expected Geant4-version-dependent mismatch indices
Placing it under `optiphy/ana` makes it easier to treat as a reusable analysis/helper script rather than a one-off test-local file.
### CI cleanup
- remove the separate `tests/test_simg4ox.sh` invocation from `.github/workflows/build-pull-request.yaml`
- rely on the existing `ctest --test-dir "$SIMPHONY_BUILD" --output-on-failure` step to run `Integration.simg4ox`
This avoids running the same test twice in PR CI.1 parent c83319d commit 4260e06
6 files changed
Lines changed: 147 additions & 59 deletions
File tree
- .github/workflows
- optiphy/ana
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
190 | 189 | | |
191 | 190 | | |
192 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | 36 | | |
29 | 37 | | |
| |||
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
56 | | - | |
57 | 64 | | |
58 | | - | |
59 | 65 | | |
60 | | - | |
61 | 66 | | |
62 | | - | |
63 | 67 | | |
64 | | - | |
65 | 68 | | |
66 | | - | |
67 | 69 | | |
68 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | | - | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments