Skip to content

Commit 9395a5d

Browse files
authored
Merge pull request #7 from LinuxDevon/Cmake-Test-Action
Adding in a test action file from cmake example
2 parents c13d1fe + d4ae428 commit 9395a5d

File tree

7 files changed

+42
-11
lines changed

7 files changed

+42
-11
lines changed

.github/workflows/tests.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Libdbc Tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
8+
env:
9+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
10+
BUILD_TYPE: Release
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Configure CMake
20+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
21+
22+
- name: Build
23+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j
24+
25+
- 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
29+

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "third_party/Catch2"]
2-
path = third_party/Catch2
3-
url = https://github.com/catchorg/Catch2.git

test/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
project(tests VERSION 0.1.0)
22

3-
list(APPEND TEST_SOURCES main.cpp
3+
# Download and build Catch2 test framework
4+
Include(FetchContent)
5+
FetchContent_Declare(
6+
Catch2
7+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
8+
GIT_TAG v3.2.1
9+
)
10+
FetchContent_MakeAvailable(Catch2)
11+
12+
list(APPEND TEST_SOURCES
413
test_dbc.cpp
514
test_utils.cpp)
615

7-
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/Catch2/single_include)
8-
916
add_executable(tests ${TEST_SOURCES} ${SOURCE})
17+
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
1018

1119
add_custom_target(test
1220
COMMAND ${PROJECT_NAME}

test/main.cpp

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/test_dbc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <catch2/catch.hpp>
1+
#include <catch2/catch_test_macros.hpp>
22
#include "defines.hpp"
33
#include <libdbc/dbc.hpp>
44

test/test_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <catch2/catch.hpp>
1+
#include <catch2/catch_test_macros.hpp>
22
#include "defines.hpp"
33
#include <libdbc/utils/utils.hpp>
44

third_party/Catch2

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)