diff --git a/README.md b/README.md index 50bdbb5..c6b9639 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/cmake/Targets.cmake b/cmake/Targets.cmake index 1129159..94078da 100644 --- a/cmake/Targets.cmake +++ b/cmake/Targets.cmake @@ -19,6 +19,9 @@ set_property(CACHE VOID_TARGET PROPERTY STRINGS auto ${VOID_KNOWN_TARGETS}) # native I/O, spawns processes, loads shared libraries, uses SQLite, or needs # C++26 reflection. Keep this list fail-closed: a module is added only after # it has been configured and compiled for wasm32-unknown-emscripten. +# Qualified with Emscripten 6.0.9 (Clang 22, libc++) for configure, build, +# install, consume and run under Node; the wasm test suite is not qualified +# yet (see docs/targets.md). set(VOID_WASM_MODULES Algorithms Binary diff --git a/docs/targets.md b/docs/targets.md index 7a7d9b8..a8af84d 100644 --- a/docs/targets.md +++ b/docs/targets.md @@ -70,23 +70,33 @@ message(STATUS "Void target: ${VOID_TARGET_MANIFEST_TARGET}") The Linux profile is the reference target: every module is allowed and the per-module platform code selects the native implementation. -### Linux / musl (unqualified) +### Linux / musl (configure/build/install/consume qualified) | Item | Value | |------|-------| -| Triple | `x86_64-alpine-linux-musl` | -| Compiler | Alpine GCC 14.2+ or Clang 19+ | -| Standard library | libstdc++ (or libc++) with musl 1.2.5 | -| CMake / generator | CMake 4.0+, Ninja | -| Dependencies | `boost-dev`, `openssl-dev`, `sqlite-dev`, `lua5.4-dev` from apk | -| Modules | all (no allowlist) | -| Status | **not qualified**: no musl toolchain in the qualification environment | +| Triple | `x86_64-alpine-linux-musl` (Alpine 3.23.8, musl 1.2.5-r24) | +| Compiler | Alpine GCC 15.2.0 (Clang accepted by the allowlist) | +| Standard library | libstdc++ with musl 1.2.5 | +| CMake / generator | CMake 4.1.3, Ninja 1.13.2 | +| Dependencies | `boost-dev` 1.84.0, `openssl-dev` 3.5.10, `sqlite-dev` 3.53.4, `lua5.4-dev` 5.4.8, `linux-headers` from apk | +| Language | C++26, reflection `no` (GCC 15), `` `yes` | +| Modules | `Async Binary Containers Core Crypto Data Functional FunctionalCoreFormatting IO IPC LogState Math Memory Net ObservabilityHooks Resilience Sqlite System SystemAsync Text Time` | +| Observed | RelWithDebInfo with `-DVOID_WARNINGS_AS_ERRORS=ON` and `-DVOID_ENABLE_TESTING=OFF`: configure detected `linux-musl`, build passed, `cmake --install` to a prefix succeeded, and the isolated `TargetProfile` consumer configured, linked, and ran (`VoidTargetProfileConsumer` 1/1) recording `target=linux-musl triple=x86_64-alpine-linux-musl compiler=GNU-15.2.0 linkage=shared reflection=no` | + +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`) 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 -recognized and configured like Linux, but no Alpine build has been observed, -so musl-specific behaviour (subprocess `/proc`, `dl`, locale) must not be -assumed. Record the exact tuple before claiming support. +recognized and configured like Linux; musl-specific behaviour (subprocess +`/proc`, `dl`, locale) must still be verified before claiming full support. ### Windows client (compile/install/consume + Wine runtime qualified) @@ -137,23 +147,67 @@ cmake -S . -B build-mingw -G Ninja \ A regular MinGW-w64 installation with winpthreads does not need those extra flags. -### Browser / Wasm subset (unqualified) +### Browser / Wasm subset (library qualified, test suite unqualified) | Item | Value | |------|-------| | Triple | `wasm32-unknown-emscripten` | -| Compiler | Emscripten Clang (4.x) | +| Compiler | Emscripten 6.0.9 (Clang 22.1.8) | | Standard library | libc++ + Emscripten libc | -| CMake / generator | CMake 4.0+ via `emcmake`, Ninja | +| CMake / generator | CMake 4.5 via `emcmake`, Ninja, Node 24.22.3 as the test emulator | | Language | C++26 without reflection (`VOID_HAS_CXX26_REFLECTION=no`) | | Modules | `Algorithms Binary Containers Core Data Functional LogState Math Memory Testing TestingMock Text Time Unicode` | -| Status | **not qualified**: no Emscripten toolchain in the qualification environment | +| Observed | configure, compile, `cmake --install`, consume (`find_package(Void)`) and run the consumer under Node (`node_exit=0`) | The allowlist is fail-closed: native networking (`Net`, `RPC`), processes and filesystem (`System`, `SystemAsync`), IPC, SQLite, plugins and anything that -needs threads or reflection stay out. ThreadSanitizer is rejected for -`wasm`. Do not add a module until it has been configured and compiled with -`emcmake`. +needs threads or reflection stay out. Do not add a module until it has been +configured and compiled with `emcmake`. + +Verified commands: + +```bash +# Library subset +emcmake cmake -S . -B build-wasm -G Ninja -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_SCAN_FOR_MODULES=OFF \ + -DVOID_ENABLE_TESTING=OFF \ + -DVOID_ENABLED_MODULES="Algorithms;Binary;Containers;Core;Data;Functional;LogState;Math;Memory;Testing;TestingMock;Text;Time;Unicode" +cmake --build build-wasm +cmake --install build-wasm --prefix "$PWD/build-wasm-install" + +# Consumer (the install lives outside the Emscripten sysroot) +emcmake cmake -S tests/package/TargetProfile -B build-wasm-consumer -G Ninja \ + -DCMAKE_PREFIX_PATH="$PWD/build-wasm-install" \ + -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \ + -DCMAKE_CXX_SCAN_FOR_MODULES=OFF \ + -DVOID_EXPECTED_TARGET=wasm +cmake --build build-wasm-consumer +node build-wasm-consumer/void_target_profile_consumer.js +``` + +`CMAKE_CXX_SCAN_FOR_MODULES=OFF` avoids CMake's C++20 module dependency +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 (7 translation units after the +reflection gating below). The remaining blockers are libc++ gaps, not +reflection: + +- `Core/Publication` uses `std::atomic>`, whose + specialization is not implemented by this libc++ (`__cpp_lib_atomic_shared_ptr` + absent). A portable fallback is needed. +- 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. ## Sanitizers diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6ab97e2..09100c5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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) @@ -130,6 +145,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=$") foreach(mod ${ACTIVE_MODULES}) if(NOT mod STREQUAL "Testing" AND TARGET Void::${mod}) target_link_libraries(VoidTests PRIVATE Void::${mod}) diff --git a/tests/standalone/Configuration/ArgparseReflect.cpp b/tests/standalone/Configuration/ArgparseReflect.cpp index f7684f4..079abdc 100644 --- a/tests/standalone/Configuration/ArgparseReflect.cpp +++ b/tests/standalone/Configuration/ArgparseReflect.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Configuration/Bind.cpp b/tests/standalone/Configuration/Bind.cpp index 721cf12..3bd79af 100644 --- a/tests/standalone/Configuration/Bind.cpp +++ b/tests/standalone/Configuration/Bind.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Configuration/BindAnnotations.cpp b/tests/standalone/Configuration/BindAnnotations.cpp index 46714bc..d991383 100644 --- a/tests/standalone/Configuration/BindAnnotations.cpp +++ b/tests/standalone/Configuration/BindAnnotations.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Configuration/ConfigurationHardening.cpp b/tests/standalone/Configuration/ConfigurationHardening.cpp index 74d4581..407e847 100644 --- a/tests/standalone/Configuration/ConfigurationHardening.cpp +++ b/tests/standalone/Configuration/ConfigurationHardening.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/ConfigurationAsync/ConfigurationAsync.cpp b/tests/standalone/ConfigurationAsync/ConfigurationAsync.cpp index 68d27b4..74ad2b8 100644 --- a/tests/standalone/ConfigurationAsync/ConfigurationAsync.cpp +++ b/tests/standalone/ConfigurationAsync/ConfigurationAsync.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Core/FlagsReflect.cpp b/tests/standalone/Core/FlagsReflect.cpp index 810270d..0d3fb6f 100644 --- a/tests/standalone/Core/FlagsReflect.cpp +++ b/tests/standalone/Core/FlagsReflect.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Core/Meta.cpp b/tests/standalone/Core/Meta.cpp index 239320b..772fd37 100644 --- a/tests/standalone/Core/Meta.cpp +++ b/tests/standalone/Core/Meta.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Data/CsvReflect.cpp b/tests/standalone/Data/CsvReflect.cpp index 2121e79..648d6df 100644 --- a/tests/standalone/Data/CsvReflect.cpp +++ b/tests/standalone/Data/CsvReflect.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Data/Reflect.cpp b/tests/standalone/Data/Reflect.cpp index 62919a8..07d5f0e 100644 --- a/tests/standalone/Data/Reflect.cpp +++ b/tests/standalone/Data/Reflect.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Data/ReflectAnnotations.cpp b/tests/standalone/Data/ReflectAnnotations.cpp index dde314c..ab585a3 100644 --- a/tests/standalone/Data/ReflectAnnotations.cpp +++ b/tests/standalone/Data/ReflectAnnotations.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Data/ReflectChrono.cpp b/tests/standalone/Data/ReflectChrono.cpp index 0e55ff6..14ede07 100644 --- a/tests/standalone/Data/ReflectChrono.cpp +++ b/tests/standalone/Data/ReflectChrono.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Fsm/Entry.cpp b/tests/standalone/Fsm/Entry.cpp index 40e0f93..60bc314 100644 --- a/tests/standalone/Fsm/Entry.cpp +++ b/tests/standalone/Fsm/Entry.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Fsm/FsmHardening.cpp b/tests/standalone/Fsm/FsmHardening.cpp index 07a4d00..8944286 100644 --- a/tests/standalone/Fsm/FsmHardening.cpp +++ b/tests/standalone/Fsm/FsmHardening.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Functional/ResultReflectionFormat.cpp b/tests/standalone/Functional/ResultReflectionFormat.cpp index 2ab7c6e..ddd661b 100644 --- a/tests/standalone/Functional/ResultReflectionFormat.cpp +++ b/tests/standalone/Functional/ResultReflectionFormat.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include diff --git a/tests/standalone/Testing/ContainerFixture.cpp b/tests/standalone/Testing/ContainerFixture.cpp index 9ec695d..ce365fd 100644 --- a/tests/standalone/Testing/ContainerFixture.cpp +++ b/tests/standalone/Testing/ContainerFixture.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include diff --git a/tests/standalone/TestingMock/Reflect.cpp b/tests/standalone/TestingMock/Reflect.cpp index 77640ea..2cbc564 100644 --- a/tests/standalone/TestingMock/Reflect.cpp +++ b/tests/standalone/TestingMock/Reflect.cpp @@ -1,3 +1,4 @@ +// @requires-reflection #include #include #include