Skip to content

Adding in a test action file from cmake example #7

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

Merged
merged 4 commits into from
Jan 6, 2023
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
29 changes: 29 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Libdbc Tests

on:
push:
branches: [ "master" ]
pull_request:

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j

- name: Test
working-directory: ${{github.workspace}}/build
# Didn't configure to use ctest. Opted for a custom target to run instead
run: cmake --build ${{github.workspace}}/build --target test -- -j

3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "third_party/Catch2"]
path = third_party/Catch2
url = https://github.com/catchorg/Catch2.git
14 changes: 11 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
project(tests VERSION 0.1.0)

list(APPEND TEST_SOURCES main.cpp
# Download and build Catch2 test framework
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.2.1
)
FetchContent_MakeAvailable(Catch2)

list(APPEND TEST_SOURCES
test_dbc.cpp
test_utils.cpp)

include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/Catch2/single_include)

add_executable(tests ${TEST_SOURCES} ${SOURCE})
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)

add_custom_target(test
COMMAND ${PROJECT_NAME}
Expand Down
2 changes: 0 additions & 2 deletions test/main.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_dbc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include "defines.hpp"
#include <libdbc/dbc.hpp>

Expand Down
2 changes: 1 addition & 1 deletion test/test_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include "defines.hpp"
#include <libdbc/utils/utils.hpp>

Expand Down
1 change: 0 additions & 1 deletion third_party/Catch2
Submodule Catch2 deleted from de6fe1