mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-09 21:00:06 +00:00
Include test sources to pick up functions and classes from the module rather than from the non-modular library which is baked into the test-main
library. (#2356)
This averts linker problems: - strong ownership model: missing linker symbols - weak ownership model: duplicate linker symbols Simplify `gtest-extra.cc` while at it.
This commit is contained in:
parent
02ad5e11da
commit
f2b03facd9
@ -41,7 +41,7 @@ function(add_fmt_test name)
|
|||||||
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)
|
set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wno-weak-vtables)
|
||||||
endif ()
|
endif ()
|
||||||
elseif (ADD_FMT_TEST_MODULE)
|
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)
|
set_source_files_properties(${name}.cc PROPERTIES OBJECT_DEPENDS test-module)
|
||||||
else ()
|
else ()
|
||||||
set(libs test-main fmt)
|
set(libs test-main fmt)
|
||||||
@ -97,7 +97,7 @@ if (FMT_CAN_MODULE)
|
|||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
|
||||||
enable_module(test-module)
|
enable_module(test-module)
|
||||||
|
|
||||||
add_fmt_test(module-test MODULE)
|
add_fmt_test(module-test MODULE test-main.cc)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus
|
target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus
|
||||||
/Zc:externConstexpr /Zc:inline)
|
/Zc:externConstexpr /Zc:inline)
|
||||||
|
@ -32,11 +32,10 @@ output_redirect::~output_redirect() FMT_NOEXCEPT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void output_redirect::flush() {
|
void output_redirect::flush() {
|
||||||
# if EOF != -1
|
|
||||||
# error "FMT_RETRY assumes return value of -1 indicating failure"
|
|
||||||
# endif
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
FMT_RETRY(result, fflush(file_));
|
do {
|
||||||
|
result = fflush(file_);
|
||||||
|
} while (result == EOF && errno == EINTR);
|
||||||
if (result != 0) throw fmt::system_error(errno, "cannot flush stream");
|
if (result != 0) throw fmt::system_error(errno, "cannot flush stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,18 +35,30 @@
|
|||||||
# define FMT_USE_FCNTL 0
|
# define FMT_USE_FCNTL 0
|
||||||
#endif
|
#endif
|
||||||
#define FMT_NOEXCEPT noexcept
|
#define FMT_NOEXCEPT noexcept
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
|
# define FMT_POSIX(call) _##call
|
||||||
|
#else
|
||||||
|
# define FMT_POSIX(call) call
|
||||||
|
#endif
|
||||||
|
#define FMT_OS_H_ // don't pull in os.h directly or indirectly
|
||||||
|
|
||||||
import fmt;
|
import fmt;
|
||||||
|
|
||||||
// check for macros leaking from BMI
|
// check for macros leaking from BMI
|
||||||
static bool macro_leaked =
|
static bool macro_leaked =
|
||||||
#if defined(FMT_CORE_H_) || defined(FMT_FORMAT_H)
|
#if defined(FMT_CORE_H_) || defined(FMT_FORMAT_H_)
|
||||||
true;
|
true;
|
||||||
#else
|
#else
|
||||||
false;
|
false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gtest-extra.h"
|
// Include sources to pick up functions and classes from the module rather than
|
||||||
|
// from the non-modular library which is baked into the 'test-main' library.
|
||||||
|
// This averts 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
|
// an implicitly exported namespace must be visible [module.interface]/2.2
|
||||||
TEST(module_test, namespace) {
|
TEST(module_test, namespace) {
|
||||||
|
Loading…
Reference in New Issue
Block a user