diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dcf3f4ac258e..5dbd529ca9e0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,7 +41,7 @@ function(add_fmt_test name) set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables) endif () elseif (ADD_FMT_TEST_MODULE) - set(libs test-main test-module) + set(libs gtest test-module) set_source_files_properties(${name}.cc PROPERTIES OBJECT_DEPENDS test-module) else () set(libs test-main fmt) @@ -97,7 +97,7 @@ if (FMT_CAN_MODULE) $) enable_module(test-module) - add_fmt_test(module-test MODULE) + add_fmt_test(module-test MODULE test-main.cc) if (MSVC) target_compile_options(test-module PRIVATE /utf-8) target_compile_options(module-test PRIVATE /utf-8) diff --git a/test/module-test.cc b/test/module-test.cc index 69b6099a7b97..b95758fcfdcf 100644 --- a/test/module-test.cc +++ b/test/module-test.cc @@ -35,18 +35,41 @@ # define FMT_USE_FCNTL 0 #endif #define FMT_NOEXCEPT noexcept +#ifndef FMT_POSIX +# if defined(_WIN32) && !defined(__MINGW32__) +# define FMT_POSIX(call) _##call +# else +# define FMT_POSIX(call) call +# endif +#endif +#ifndef _WIN32 +# define FMT_RETRY_VAL(result, expression, error_result) \ + do { \ + (result) = (expression); \ + } while ((result) == (error_result) && errno == EINTR) +#else +# define FMT_RETRY_VAL(result, expression, error_result) result = (expression) +#endif +#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1) +#define FMT_OS_H_ import fmt; // check for macros leaking from BMI static bool macro_leaked = -#if defined(FMT_CORE_H_) || defined(FMT_FORMAT_H) +#if defined(FMT_CORE_H_) || defined(FMT_FORMAT_H_) true; #else false; #endif -#include "gtest-extra.h" +// Include sources to pick up functions and classes from the module rather than +// from the non-modular library that's baked into the 'test-main' library. +// This avoids linker problems: +// - strong ownership model: missing linker symbols +// - weak ownership model: duplicate linker symbols +#include "gtest-extra.cc" +#include "util.cc" // an implicitly exported namespace must be visible [module.interface]/2.2 TEST(module_test, namespace) {