File tree Expand file tree Collapse file tree 4 files changed +29
-17
lines changed
Expand file tree Collapse file tree 4 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -17,13 +17,18 @@ jobs:
1717 - uses : actions/checkout@v3
1818
1919 - name : Configure CMake
20- run : cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
20+ run : |
21+ mkdir build
22+ cd build
23+ cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ..
2124
2225 - name : Build
23- run : cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j
26+ run : |
27+ cd build
28+ make
2429
2530 - name : Test
26- working-directory : ${{github.workspace}}/build
27- # Didn't configure to use ctest. Opted for a custom target to run instead
28- run : cmake --build ${{github.workspace}}/build --target test -- -j
31+ run : |
32+ cd build
33+ ctest --output-on-failure
2934
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.10)
33project (dbc)
44
55option (DEBUG "use debug flag" NO )
6+ option (ENABLE_TESTS "Enable Unittests" ON )
67
78# specify the C++ standard
89set (CMAKE_CXX_STANDARD 11)
@@ -31,7 +32,11 @@ list(APPEND SOURCE ${PROJECT_SOURCE_DIR}/src/utils.cpp
3132include_directories (src)
3233include_directories (include )
3334
34- add_subdirectory (test )
35+ if (ENABLE_TESTS)
36+ include (CTest)
37+ add_subdirectory (test )
38+ endif ()
39+
3540add_subdirectory (doc )
3641
3742add_library (${PROJECT_NAME} STATIC ${SOURCE} )
Original file line number Diff line number Diff line change 1- project (tests VERSION 0.1.0 )
1+ enable_testing ( )
22
33# Download and build Catch2 test framework
44Include (FetchContent)
@@ -14,9 +14,11 @@ list(APPEND TEST_SOURCES
1414 test_utils.cpp)
1515
1616add_executable (tests ${TEST_SOURCES} ${SOURCE} )
17+ target_compile_definitions (tests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR} /dbcs" )
1718target_link_libraries (tests PRIVATE Catch2::Catch2WithMain)
19+ target_sources (tests INTERFACE FILE_SET HEADERS
20+ TYPE HEADERS
21+ BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
22+ FILES defines.hpp)
1823
19- add_custom_target (test
20- COMMAND ${PROJECT_NAME}
21- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
22- DEPENDS ${PROJECT_NAME} )
24+ add_test (NAME tests COMMAND $<TARGET_FILE:tests>)
Original file line number Diff line number Diff line change 11#include < string>
22
33// Correctly formated files
4- static const std::string COMPLEX_DBC_FILE = " ./dbcs /Complex.dbc" ;
5- static const std::string SIMPLE_DBC_FILE = " ./dbcs /Simple.dbc" ;
4+ static const std::string COMPLEX_DBC_FILE = std::string(TESTDBCFILES_PATH) + " /Complex.dbc" ;
5+ static const std::string SIMPLE_DBC_FILE = std::string(TESTDBCFILES_PATH) + " /Simple.dbc" ;
66
77// Files with Errors
8- static const std::string MISSING_NEW_SYMBOLS_DBC_FILE = " ./dbcs /MissingNewSymbols.dbc" ;
9- static const std::string MISSING_VERSION_DBC_FILE = " ./dbcs /MissingVersion.dbc" ;
10- static const std::string MISSING_BIT_TIMING_DBC_FILE = " ./dbcs /MissingBitTiming.dbc" ;
11- static const std::string TEXT_FILE = " ./dbcs /TextFile.txt" ;
8+ static const std::string MISSING_NEW_SYMBOLS_DBC_FILE = std::string(TESTDBCFILES_PATH) + " /MissingNewSymbols.dbc" ;
9+ static const std::string MISSING_VERSION_DBC_FILE = std::string(TESTDBCFILES_PATH) + " /MissingVersion.dbc" ;
10+ static const std::string MISSING_BIT_TIMING_DBC_FILE = std::string(TESTDBCFILES_PATH) + " /MissingBitTiming.dbc" ;
11+ static const std::string TEXT_FILE = std::string(TESTDBCFILES_PATH) + " /TextFile.txt" ;
You can’t perform that action at this time.
0 commit comments