Skip to content

CI: cover the reflection path of testing/type_name.hpp in the build-and-test matrix #88

Description

@steve-downey

tests/beman/expected/testing/type_name.hpp has two implementations of the same contract:

  • Reflection (P2996)std::meta::display_string_of(^^T), selected when __cpp_lib_reflection and __cpp_impl_reflection are both defined.
  • Fallback — recovers the spelling from std::source_location::function_name() by calibrating on the signatures of signature<bool> and signature<char>.

Only the fallback is covered by CI today. The reflection path is exercised locally by make TOOLCHAIN=gcc-16, because cmake/gcc-16-toolchain.cmake adds -freflection, but nothing in CI runs that toolchain.

Why the preset matrix can't cover it

The obvious move — a gcc-reflection-* preset in the preset-test matrix — does not work. The preset toolchains under infra/cmake/ set CMAKE_CXX_COMPILER to the unversioned g++, so the preset would build with whatever the user's default compiler is. g++-16 is nobody's default yet, and gcc rejects -freflection outright below -std=c++26 (a hard error, not a warning), so such a preset would break the build for almost everyone who ran it locally.

That is why the flag lives in cmake/gcc-16-toolchain.cmake, which pins CMAKE_CXX_COMPILER to g++-16 and already pins -std=gnu++26.

Candidate approach

The build-and-test matrix in .github/workflows/ci_tests.yml is the right place: it already pins explicit compiler versions, and the gcc-16 rows already select c++26:

{ "versions": ["16"],
  "tests": [
    { "cxxversions": ["c++26"],
      "tests": [
        "Debug.Default", "Release.Default", ...,
        "Debug.-DBEMAN_EXPECTED_USE_MODULES=On"
      ]

Entries accept extra cmake args in the "<Config>.<arg>" shape, so something like "Debug.-DCMAKE_CXX_FLAGS=-freflection" is the shape to aim for.

Open question before doing this: whether bemanproject/infra-workflows' reusable-beman-build-and-test.yml sets CMAKE_CXX_FLAGS itself. If it does, passing -DCMAKE_CXX_FLAGS would clobber the -std=c++26 selection and silently test the wrong thing (or fail). The reusable workflow needs reading before this is wired up — and it may need an append-style knob rather than an override.

Acceptance

  • A CI job builds and runs the test suite with -freflection on gcc-16 / c++26.
  • The job demonstrably takes the reflection branch rather than silently falling back. Note that __cpp_lib_reflection is a library macro and is undefined until <version> is included; the header handles this, but a coverage job that gets it wrong would look green while testing nothing new.
  • The fallback path keeps its existing coverage — both implementations should stay tested.

Notes

The two implementations currently produce byte-identical spellings for every type the test suite uses, so this is about preventing future drift, not fixing a present discrepancy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions