abumq / easyloggingpp

C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.75k stars 918 forks source link

Build and unit test failures #827

Open semihc opened 1 year ago

semihc commented 1 year ago

Hi,

I am trying to build easyloggingpp on Ubuntu 22.4 (WSL2) with Gcc 12.1.0. The CMake configuration fails with following message:

CMake Warning (dev) at /opt/stow/cmake-3.24.3-linux-x86_64/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (GTest) does
  not match the name of the calling package (gtest).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Findgtest.cmake:152 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:78 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)

I made following changes to the CMakeFile to overcome the above issue:

semihc@ALTAY:/opt/TC/ext/easyloggingpp$ git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 538cc8a..654db04 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,7 +75,8 @@ if (test)
     require_cpp11()
     set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")

-    find_package (gtest REQUIRED)
+    #-find_package (gtest REQUIRED)
+    find_package(GTest CONFIG REQUIRED) # Gtest/mock

     include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

@@ -98,7 +99,8 @@ if (test)
     )

     # Standard linking to gtest stuff.
-    target_link_libraries(easyloggingpp-unit-tests gtest gtest_main)
+    #- target_link_libraries(easyloggingpp-unit-tests gtest gtest_main)
+    target_link_libraries(easyloggingpp-unit-tests GTest::gtest GTest::gtest_main)

     add_test(NAME easyloggingppUnitTests COMMAND easyloggingpp-unit-tests -v)
 endif()

However, This time I encounter unit test failures:

1: [----------] 11 tests from WriteAllTest (3092 ms total) 1: 1: [----------] Global test environment tear-down 1: [==========] 79 tests from 26 test suites ran. (11934 ms total) 1: [ PASSED ] 77 tests. 1: [ FAILED ] 2 tests, listed below: 1: [ FAILED ] CommandLineArgsTest.LoggingFlagsArg 1: [ FAILED ] HelpersTest.ConvertTemplateToStdString 1: 1: 2 FAILED TESTS 1/1 Test #1: easyloggingppUnitTests ...........***Failed 12.09 sec

0% tests passed, 1 tests failed out of 1

Total Test time (real) = 12.09 sec

The following tests FAILED: 1 - easyloggingppUnitTests (Failed) Errors while running CTest Output from these tests are in: /opt/TC/ext/easyloggingpp/bld_gcc/Testing/Temporary/LastTest.log Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely. semihc@ALTAY:/opt/TC/ext/easyloggingpp$

Do you have any advice to fix unit tests?

Regards, Semih

musicinmybrain commented 1 year ago

I maintain the easyloggingpp package in Fedora Linux.

I previously filed https://github.com/amrayn/easyloggingpp/issues/816 about this.

I don’t know what the root cause is, but I am working around the failures by calling easyloggingpp-unit-tests with the argument --gtest_filter=-CommandLineArgsTest.LoggingFlagsArg.