Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing #12

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(logfault
DESCRIPTION "Simple to use, header only C++ library for application-logging on all major platforms."
HOMEPAGE_URL https://github.com/jgaa/logfault
VERSION 0.5.0
VERSION 0.5.1
LANGUAGES CXX)

include(GNUInstallDirs)
Expand All @@ -27,6 +27,7 @@ option(LOGFAULT_BUILD_TESTS "Build tests" ON)

if(LOGFAULT_BUILD_TESTS)
find_package(GTest REQUIRED)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif()
Expand Down
7 changes: 5 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.build import check_max_cppstd, check_min_cppstd
from conan.tools.files import copy
from conan.tools.scm import Git


class LogfaultConan(ConanFile):
name = "logfault"
version = "0.5.0"
version = "0.5.1"
settings = "os", "arch", "compiler", "build_type"
exports_sources = "include/*", "tests/*", "CMakeLists.txt"
no_copy_source = True
Expand All @@ -23,7 +24,8 @@ def package_info(self):
self.cpp_info.libdirs = []

def requirements(self):
self.test_requires("gtest/1.14.0")
if not self.conf.get("tools.build:skip_test", default=False):
self.test_requires("gtest/1.14.0")

def validate(self):
check_min_cppstd(self, 14)
Expand All @@ -40,6 +42,7 @@ def build(self):

def package(self):
# This will also copy the "include" folder
copy(self, "LICENSE", self.source_folder, self.package_folder)
copy(self, "*.h", self.source_folder, self.package_folder)

def package_info(self):
Expand Down
12 changes: 12 additions & 0 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project (example)

find_package (Threads)
find_package (Logfault REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE
logfault::logfault
Threads::Threads
)

26 changes: 26 additions & 0 deletions test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.build import can_run


class helloTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def layout(self):
cmake_layout(self)

def test(self):
if can_run(self):
cmd = os.path.join(self.cpp.build.bindir, "example")
self.run(cmd, env="conanrun")
13 changes: 13 additions & 0 deletions test_package/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

// General tests for manual testing during development

#include <iostream>
#include "logfault/logfault.h"

using namespace std;

int main( int argc, char *argv[]) {

logfault::LogManager::Instance().AddHandler(std::make_unique<logfault::StreamHandler>(clog, logfault::LogLevel::DEBUGGING));
LFLOG_INFO << "Testing" << 1 << 2 << 3;
}
38 changes: 2 additions & 36 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@


message ("GTEST_LIBRARIES: ${GTEST_LIBRARIES}")
message ("GTest_LIBRARIES: ${GTest_LIBRARIES}")

message ("GTEST_INCLUDE_DIRS: ${GTEST_INCLUDE_DIRS}")
message ("GTest_INCLUDE_DIRS: ${GTest_INCLUDE_DIRS}")

if (NOT GTEST_LIBRARIES)
set (GTEST_LIBRARIES ${GTest_LIBRARIES})
endif()

if (NOT GTEST_INCLUDE_DIRS)
set (GTEST_INCLUDE_DIRS ${GTest_INCLUDE_DIRS})
endif()

option(WITH_QT "Enable QT" OFF)

# if (WITH_QT)
# add_definitions(-DLOGFAULT_USE_QT_LOG=1)
# find_package(Qt6 6.4 REQUIRED COMPONENTS Test)
# qt_standard_project_setup(REQUIRES 6.5)
# qt_add_executable(general_tests general_tests.cpp)

# else()
# add_executable(general_tests general_tests.cpp)
# target_link_libraries(general_tests
# ${DEFAULT_LIBRARIES}
# )
# endif()

####### default_to_clog


add_executable(default_to_clog
default_to_clog.cpp
)
Expand All @@ -43,12 +11,11 @@ target_include_directories(default_to_clog
${CMAKE_CURRENT_SOURCE_DIR}
${LOGFAULT_ROOT}/include
${GTEST_INCLUDE_DIRS}
#${GTest_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/exports
)

target_link_libraries(default_to_clog
${GTEST_LIBRARIES}
GTest::gtest
${CMAKE_THREAD_LIBS_INIT}
)

Expand All @@ -69,12 +36,11 @@ target_include_directories(default_to_clog_with_tid
${CMAKE_CURRENT_SOURCE_DIR}
${LOGFAULT_ROOT}/include
${GTEST_INCLUDE_DIRS}
#${GTest_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}/exports
)

target_link_libraries(default_to_clog_with_tid
${GTEST_LIBRARIES}
GTest::gtest
${CMAKE_THREAD_LIBS_INIT}
)

Expand Down
Loading