Skip to content

Commit c368f5f

Browse files
enable fmt_module tests by updating module-test.cc
- Update g++ module testing to use g++ version 15 instead of 14. The module support in version 14 isn't very stable and the module testing was not working due to unresolved locale symbols. - Refactor test/CMakeLists.txt to enable testing for modules - The tests in `module-test.cc` seem to not have been updated in some time despite changes in the main library. - Wide String versions of several tests appear to be deprecated so have been commented out. - Refactored tests related to `fmt::format_args` that now requires lvalue references as opposed to direct values. - MSVC has some bugs that are still present since the module-test.cc file was initially written. We update the version detection to current versions. - MSVC and the other compilers take different paths in determining the fmt::detail namespace. Used #ifdef macros to enforce this. This enables module testing to work on all compilers - clang-format base.h due to lint failure on CI
1 parent cdb8dc7 commit c368f5f

File tree

4 files changed

+126
-72
lines changed

4 files changed

+126
-72
lines changed

.github/workflows/linux.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333
std: 23
3434
install: sudo apt install g++-13
3535
shared: -DBUILD_SHARED_LIBS=ON
36-
- cxx: g++-14
36+
- cxx: g++-15
3737
build_type: Release
3838
std: 23
39-
install: sudo apt install g++-14
39+
install: sudo apt install g++-15
4040
- cxx: clang++-11
4141
build_type: Debug
4242
std: 17
@@ -140,7 +140,7 @@ jobs:
140140
- name: Add repositories for newer GCC
141141
run: |
142142
sudo apt-add-repository ppa:ubuntu-toolchain-r/test
143-
if: ${{ matrix.cxx == 'g++-13' || matrix.cxx == 'g++-14' }}
143+
if: ${{ matrix.cxx == 'g++-13' || matrix.cxx == 'g++-15' }}
144144

145145
- name: Install LLVM-20
146146
run: |
@@ -180,7 +180,7 @@ jobs:
180180
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
181181
-DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON \
182182
${{matrix.fuzz}} ${{matrix.shared}} $GITHUB_WORKSPACE
183-
if: ${{ matrix.cxx != 'clang++-20' && matrix.cxx != 'g++-14' }}
183+
if: ${{ matrix.cxx != 'clang++-20' && matrix.cxx != 'g++-15' }}
184184

185185
- name: Configure-Modules
186186
working-directory: ${{runner.workspace}}/build
@@ -196,7 +196,7 @@ jobs:
196196
-DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \
197197
-DFMT_DOC=OFF -DFMT_PEDANTIC=ON \
198198
${{matrix.fuzz}} ${{matrix.shared}} $GITHUB_WORKSPACE
199-
if: ${{ matrix.cxx == 'clang++-20' || matrix.cxx == 'g++-14' }}
199+
if: ${{ matrix.cxx == 'clang++-20' || matrix.cxx == 'g++-15' }}
200200

201201
- name: Build
202202
working-directory: ${{runner.workspace}}/build

include/fmt/base.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,10 +1872,10 @@ template <typename OutputIt, typename T, typename = void>
18721872
struct has_insert : std::false_type {};
18731873

18741874
template <typename OutputIt, typename T>
1875-
struct has_insert<OutputIt, T,
1876-
void_t<decltype(get_container(std::declval<OutputIt>())
1877-
.insert({}, std::declval<T>(),
1878-
std::declval<T>()))>>
1875+
struct has_insert<
1876+
OutputIt, T,
1877+
void_t<decltype(get_container(std::declval<OutputIt>())
1878+
.insert({}, std::declval<T>(), std::declval<T>()))>>
18791879
: std::true_type {};
18801880

18811881
// An optimized version of std::copy with the output value type (T).

test/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function (add_fmt_test name)
1919
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)
2020
endif ()
2121
elseif (ADD_FMT_TEST_MODULE)
22-
set(libs test-main)
22+
set(libs test-main fmt-module)
2323
else ()
2424
set(libs test-main fmt)
2525
endif ()
@@ -81,9 +81,7 @@ add_executable(perf-sanity perf-sanity.cc)
8181
target_link_libraries(perf-sanity fmt::fmt)
8282

8383
if (FMT_MODULE)
84-
# Module tests are currently disabled.
85-
# add_fmt_test(module-test MODULE test-main.cc)
86-
# target_link_libraries(module-test fmt-module)
84+
add_fmt_test(module-test MODULE)
8785
endif ()
8886

8987
if (NOT DEFINED MSVC_STATIC_RUNTIME AND MSVC)

0 commit comments

Comments
 (0)