From 7f14bfbca860e97be57fb99a715ab900c7f0678d Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Tue, 27 Apr 2021 00:55:46 +0300 Subject: [PATCH] move gmock files, update gmock usages * all gmock/gtest files moved to `gmock` directory (like a library name) * CMake `gmock` target updated to export includes as "gtest/gtest.h" or "gmock/gtest.h" only * includes in tests updated: "gtest.h" -> "gtest/gtest.h", "gmock.h" -> "gmock/gmock.h" * removed duplications of `target_include_directories` for gmock directories (CMake manages them) * `.clang-format` file added to `gmock` directory to prevent formatting there --- test/CMakeLists.txt | 9 +++------ test/args-test.cc | 2 +- test/assert-test.cc | 2 +- test/compile-test.cc | 2 +- test/core-test.cc | 2 +- test/format-impl-test.cc | 2 +- test/format-test.cc | 2 +- test/gmock/.clang-format | 3 +++ test/{ => gmock}/gmock-gtest-all.cc | 0 test/gmock/{ => include/gmock}/gmock.h | 0 test/{ => gmock/include}/gtest/gtest-spi.h | 0 test/{ => gmock/include}/gtest/gtest.h | 0 test/gtest-extra.h | 2 +- test/locale-test.cc | 2 +- test/mock-allocator.h | 2 +- test/ostream-test.cc | 2 +- test/posix-mock-test.cc | 2 +- test/ranges-test.cc | 2 +- test/scan-test.cc | 2 +- test/std-format-test.cc | 2 +- test/test-assert.h | 2 +- test/test-main.cc | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) create mode 100644 test/gmock/.clang-format rename test/{ => gmock}/gmock-gtest-all.cc (100%) rename test/gmock/{ => include/gmock}/gmock.h (100%) rename test/{ => gmock/include}/gtest/gtest-spi.h (100%) rename test/{ => gmock/include}/gtest/gtest.h (100%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6ab80dee862dd..409c22ba6fdb0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,9 +6,10 @@ # pre-compiled copy of Google Test (for example, into /usr/local)?" # at http://code.google.com/p/googletest/wiki/FAQ for more details. add_library(gmock STATIC - gmock-gtest-all.cc gmock/gmock.h gtest/gtest.h gtest/gtest-spi.h) + gmock/gmock-gtest-all.cc gmock/include/gmock/gmock.h + gmock/include/gtest/gtest.h gmock/include/gtest/gtest-spi.h) target_compile_definitions(gmock PUBLIC GTEST_HAS_STD_WSTRING=1) -target_include_directories(gmock SYSTEM PUBLIC . gmock gtest) +target_include_directories(gmock SYSTEM PUBLIC gmock/include) find_package(Threads) if (Threads_FOUND) @@ -37,7 +38,6 @@ target_compile_definitions(gmock set(TEST_MAIN_SRC test-main.cc gtest-extra.cc gtest-extra.h util.cc) add_library(test-main STATIC ${TEST_MAIN_SRC}) -target_include_directories(test-main SYSTEM PUBLIC gtest gmock) target_link_libraries(test-main gmock fmt) include(CheckCXXCompilerFlag) @@ -75,7 +75,6 @@ function(add_fmt_test name) if (FMT_WERROR) target_compile_options(${name} PRIVATE ${WERROR_FLAG}) endif () - target_include_directories(${name} SYSTEM PUBLIC gtest gmock) add_test(NAME ${name} COMMAND ${name}) endfunction() @@ -123,7 +122,6 @@ if (NOT MSVC_STATIC_RUNTIME) target_include_directories( posix-mock-test PRIVATE ${PROJECT_SOURCE_DIR}/include) target_link_libraries(posix-mock-test gmock) - target_include_directories(posix-mock-test SYSTEM PUBLIC gtest gmock) if (FMT_PEDANTIC) target_compile_options(posix-mock-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) endif () @@ -137,7 +135,6 @@ endif () add_fmt_executable(header-only-test header-only-test.cc header-only-test2.cc test-main.cc) target_link_libraries(header-only-test gmock) -target_include_directories(header-only-test SYSTEM PUBLIC gtest gmock) if (TARGET fmt-header-only) target_link_libraries(header-only-test fmt-header-only) else () diff --git a/test/args-test.cc b/test/args-test.cc index 3fa4f70dd82e6..a7421bc5299d0 100644 --- a/test/args-test.cc +++ b/test/args-test.cc @@ -7,7 +7,7 @@ #include "fmt/args.h" -#include "gtest.h" +#include "gtest/gtest.h" TEST(args_test, basic) { auto store = fmt::dynamic_format_arg_store(); diff --git a/test/assert-test.cc b/test/assert-test.cc index d2e5dd07dbbbe..c74e617e68f35 100644 --- a/test/assert-test.cc +++ b/test/assert-test.cc @@ -10,7 +10,7 @@ // For the license information refer to format.h. #include "fmt/core.h" -#include "gtest.h" +#include "gtest/gtest.h" TEST(assert_test, fail) { #if GTEST_HAS_DEATH_TEST diff --git a/test/compile-test.cc b/test/compile-test.cc index 56056ec4b53f8..8d015ccbe6fc8 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -15,7 +15,7 @@ #include "fmt/chrono.h" #include "fmt/compile.h" -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" #include "util.h" diff --git a/test/core-test.cc b/test/core-test.cc index 3df04618e33f2..d5a70291429bc 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -20,7 +20,7 @@ #include // std::string #include // std::is_same -#include "gmock.h" +#include "gmock/gmock.h" #if defined(FMT_COMPILE_TIME_CHECKS) && FMT_COMPILE_TIME_CHECKS # include "fmt/format.h" diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index 201aa03b2914c..c332a8c2415b9 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -15,7 +15,7 @@ #include "../src/format.cc" #include "fmt/printf.h" -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" #include "util.h" diff --git a/test/format-test.cc b/test/format-test.cc index 1145ac3adfcdd..429cd437aa826 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -30,7 +30,7 @@ #undef index -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" #include "mock-allocator.h" #include "util.h" diff --git a/test/gmock/.clang-format b/test/gmock/.clang-format new file mode 100644 index 0000000000000..ec09b9b6bb1af --- /dev/null +++ b/test/gmock/.clang-format @@ -0,0 +1,3 @@ +# Disable clang-format here +DisableFormat: true +SortIncludes: Never diff --git a/test/gmock-gtest-all.cc b/test/gmock/gmock-gtest-all.cc similarity index 100% rename from test/gmock-gtest-all.cc rename to test/gmock/gmock-gtest-all.cc diff --git a/test/gmock/gmock.h b/test/gmock/include/gmock/gmock.h similarity index 100% rename from test/gmock/gmock.h rename to test/gmock/include/gmock/gmock.h diff --git a/test/gtest/gtest-spi.h b/test/gmock/include/gtest/gtest-spi.h similarity index 100% rename from test/gtest/gtest-spi.h rename to test/gmock/include/gtest/gtest-spi.h diff --git a/test/gtest/gtest.h b/test/gmock/include/gtest/gtest.h similarity index 100% rename from test/gtest/gtest.h rename to test/gmock/include/gtest/gtest.h diff --git a/test/gtest-extra.h b/test/gtest-extra.h index 01c70ddbf06d5..001155ab1f6f3 100644 --- a/test/gtest-extra.h +++ b/test/gtest-extra.h @@ -11,7 +11,7 @@ #include #include "fmt/os.h" -#include "gmock.h" +#include "gmock/gmock.h" #define FMT_TEST_THROW_(statement, expected_exception, expected_message, fail) \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ diff --git a/test/locale-test.cc b/test/locale-test.cc index db55923dce988..2ae9b3bcb940b 100644 --- a/test/locale-test.cc +++ b/test/locale-test.cc @@ -9,7 +9,7 @@ #include -#include "gmock.h" +#include "gmock/gmock.h" using fmt::detail::max_value; diff --git a/test/mock-allocator.h b/test/mock-allocator.h index 513a62e8bb32c..d821bca4c1339 100644 --- a/test/mock-allocator.h +++ b/test/mock-allocator.h @@ -9,7 +9,7 @@ #define FMT_MOCK_ALLOCATOR_H_ #include "fmt/format.h" -#include "gmock.h" +#include "gmock/gmock.h" template class mock_allocator { public: diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 68094222fc71b..f97dd37f93f16 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -24,7 +24,7 @@ template <> struct formatter : formatter { #include "fmt/ostream.h" #include "fmt/ranges.h" -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" #include "util.h" diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index a9711c8788ee8..a40fbce9caca1 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -26,7 +26,7 @@ # undef ERROR #endif -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" #include "util.h" diff --git a/test/ranges-test.cc b/test/ranges-test.cc index 8fee3e14e6b82..c03966499d725 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -16,7 +16,7 @@ #include #include -#include "gtest.h" +#include "gtest/gtest.h" #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 601 # define FMT_RANGES_TEST_ENABLE_C_STYLE_ARRAY diff --git a/test/scan-test.cc b/test/scan-test.cc index 962de54c878d6..dcac93375a429 100644 --- a/test/scan-test.cc +++ b/test/scan-test.cc @@ -11,7 +11,7 @@ #include -#include "gmock.h" +#include "gmock/gmock.h" #include "gtest-extra.h" TEST(ScanTest, ReadText) { diff --git a/test/std-format-test.cc b/test/std-format-test.cc index 916a7c5ed3a27..7b51a6ec50b84 100644 --- a/test/std-format-test.cc +++ b/test/std-format-test.cc @@ -1,6 +1,6 @@ #include -#include "gtest.h" +#include "gtest/gtest.h" TEST(StdFormatTest, Escaping) { using namespace std; diff --git a/test/test-assert.h b/test/test-assert.h index 3406e1ba3ddb1..da0ac321cb035 100644 --- a/test/test-assert.h +++ b/test/test-assert.h @@ -10,7 +10,7 @@ #include -#include "gtest.h" +#include "gtest/gtest.h" class assertion_failure : public std::logic_error { public: diff --git a/test/test-main.cc b/test/test-main.cc index 8db257d60ba4d..b69cc5002c358 100644 --- a/test/test-main.cc +++ b/test/test-main.cc @@ -7,7 +7,7 @@ #include -#include "gtest.h" +#include "gtest/gtest.h" #ifdef _WIN32 # include