Build: gate reflection-only tests on VOID_HAS_CXX26_REFLECTION (refs #38)
This commit is contained in:
1 parent
b1933d9906
commit
1ba60d5d6a
19 files changed
+56
-12
No files matched your search
@@ -110,4 +110,7 @@ Tests are free functions or methods on a `Void::Testing::Fixture` subclass
|
||||
returning `Void::Testing::Test` (or `Void::Testing::DisabledTest`).
|
||||
Registration is automatic — the CMake test scanner parses each `.cpp` at
|
||||
configure time and generates the registration shim. Free-function tests can
|
||||
use `// @tag` and `// @skip` comment metadata.
|
||||
use `// @tag` and `// @skip` comment metadata. A file whose tests all need
|
||||
C++26 reflection can declare `// @requires-reflection`; it is skipped when
|
||||
the compiler lacks the `VOID_HAS_CXX26_REFLECTION` capability, because the
|
||||
scanner cannot evaluate `#ifdef` guards around test functions.
|
||||
+19
-11
@@ -85,10 +85,13 @@ per-module platform code selects the native implementation.
|
||||
|
||||
The test suite is **not qualified** on musl yet: with
|
||||
`VOID_ENABLE_TESTING=ON`, reflection-dependent tests
|
||||
(`tests/standalone/Core/FlagsReflect.cpp`, `Core/Meta.cpp`) fail to compile
|
||||
when `VOID_HAS_CXX26_REFLECTION` is false. Library
|
||||
configure/build/install/consume is qualified; runtime behaviour still needs
|
||||
test coverage on this profile.
|
||||
(`tests/standalone/Core/FlagsReflect.cpp`, `Core/Meta.cpp`) failed to compile
|
||||
when `VOID_HAS_CXX26_REFLECTION` is false. Those files (and the other
|
||||
reflection-only tests) now declare `// @requires-reflection` and are skipped
|
||||
by the test scanner when the capability is absent, so the suite can build;
|
||||
a full musl test run has not been repeated in this environment.
|
||||
Library configure/build/install/consume is qualified; runtime behaviour
|
||||
still needs test coverage on this profile.
|
||||
|
||||
Detection uses `CMAKE_C_COMPILER -dumpmachine` (or
|
||||
`CMAKE_C_LIBRARY_ARCHITECTURE`/`CMAKE_C_FLAGS`) matching `musl`. The profile is
|
||||
@@ -187,17 +190,22 @@ scanner calling Emscripten's `emscan-deps`, which is not shipped by every
|
||||
Emscripten package. `CMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH` is needed
|
||||
because the Emscripten toolchain restricts package lookup to its sysroot.
|
||||
|
||||
The **test suite** does not build yet on wasm (16 translation units). The
|
||||
blockers are test-side, not library-side:
|
||||
The **test suite** does not build yet on wasm (7 translation units after the
|
||||
reflection gating below). The remaining blockers are libc++ gaps, not
|
||||
reflection:
|
||||
|
||||
- Reflection tests (`Core/Meta`, `Core/FlagsReflect`, `Data/CsvReflect`,
|
||||
`Data/Reflect*`, `Functional/ResultReflectionFormat`,
|
||||
`TestingMock/Reflect`) are not guarded when reflection is unavailable.
|
||||
- `Core/Publication` uses `std::atomic<std::shared_ptr<...>>`, whose
|
||||
specialization is not implemented by this libc++ (`__cpp_lib_atomic_shared_ptr`
|
||||
absent). A portable fallback is needed.
|
||||
- `Testing/ContainerFixture` and several `TestingMock` tests need the same
|
||||
treatment.
|
||||
- Several `TestingMock` tests need `std::move_only_function`, also absent
|
||||
from this libc++.
|
||||
|
||||
Reflection-dependent test files are gated with `// @requires-reflection`
|
||||
(Core/Meta, Core/FlagsReflect, Data/CsvReflect, Data/Reflect*,
|
||||
Functional/ResultReflectionFormat, Testing/ContainerFixture,
|
||||
TestingMock/Reflect, Configuration/Fsm annotation tests) and are skipped when
|
||||
`VOID_HAS_CXX26_REFLECTION` is false, so a non-reflecting compiler no longer
|
||||
fails on scanner-generated registrations for functions hidden by `#ifdef`.
|
||||
|
||||
Runtime observations use Node; a browser runner should confirm them.
|
||||
|
||||
|
||||
@@ -11,6 +11,21 @@ get_property(ACTIVE_HEADERS GLOBAL PROPERTY VOID_ACTIVE_PUBLIC_HEADERS)
|
||||
|
||||
function(_void_test_requires_satisfied src_file active_modules active_headers out_var)
|
||||
file(READ "${src_file}" _src_content)
|
||||
# Whole-file capability gates. The test scanner is line-based and does not
|
||||
# evaluate preprocessor conditionals, so a file whose tests live inside
|
||||
# `#ifdef VOID_HAS_*_REFLECTION` would still get registrations generated
|
||||
# for functions that are not defined. Such files declare
|
||||
# `// @requires-reflection` and are skipped when the compiler cannot do
|
||||
# C++26 reflection.
|
||||
if(NOT VOID_HAS_CXX26_REFLECTION)
|
||||
string(FIND "${_src_content}" "// @requires-reflection" _needs_reflection)
|
||||
if(NOT _needs_reflection EQUAL -1)
|
||||
message(STATUS
|
||||
"[VoidTests] Skipping ${src_file} (requires C++26 reflection)")
|
||||
set(${out_var} FALSE PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
string(REGEX MATCHALL "#[ \t]*include[ \t]*[<\"](Void/[^/\">]+/[^>\"]+)[>\"]"
|
||||
_matches "${_src_content}")
|
||||
set(_ok TRUE)
|
||||
@@ -118,6 +133,8 @@ if(_all_generated)
|
||||
set_target_properties(VoidTests PROPERTIES VOID_TESTING_NO_AUTO_SCAN TRUE)
|
||||
|
||||
target_link_libraries(VoidTests PRIVATE Void::Testing)
|
||||
target_compile_definitions(VoidTests PRIVATE
|
||||
"VOID_HAS_CXX26_REFLECTION=$<BOOL:${VOID_HAS_CXX26_REFLECTION}>")
|
||||
foreach(mod ${ACTIVE_MODULES})
|
||||
if(NOT mod STREQUAL "Testing" AND TARGET Void::${mod})
|
||||
target_link_libraries(VoidTests PRIVATE Void::${mod})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Configuration/Argparse.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Configuration/Bind.hpp>
|
||||
#include <Void/Configuration/Config.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Configuration/Bind.hpp>
|
||||
#include <Void/Configuration/Config.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Configuration/Bind.hpp>
|
||||
#include <Void/Configuration/Config.hpp>
|
||||
#include <Void/Configuration/Schema.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Async/Executor.hpp>
|
||||
#include <Void/Async/Task.hpp>
|
||||
#include <Void/Configuration/ReloadController.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Core/Flags.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Core/Meta.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Data/Csv.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Data/Reflect.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Data/Reflect.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Data/Reflect.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Suite.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Fsm/Fsm.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Async/Executor.hpp>
|
||||
#include <Void/Async/Task.hpp>
|
||||
#include <Void/Data/Reflect.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Functional/Detail/Repr.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Suite.hpp>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// @requires-reflection
|
||||
#include <Void/TestingMock/Reflect.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Suite.hpp>
|
||||
|
||||
Reference in new issue
Block a user