Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/hsim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
path: ['src', 'include']
path: ['src', 'include', 'test']
steps:
- name: Checkout repo and submodules
uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ add_executable(${PROJECT_NAME} src/main.cc)
target_compile_options(${PROJECT_NAME} PRIVATE -Wpedantic)
target_link_libraries(${PROJECT_NAME} PRIVATE hSim-lib CLI11::CLI11 fmt::fmt)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME hsim)

enable_testing()
add_subdirectory(test)
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(unit)
20 changes: 20 additions & 0 deletions test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
include(GoogleTest)

# Helpful macro to add unittest
# Accepts src_file (with utest) as mandatory argument
# and list of linked libraries after it
macro(hsim_add_utest src_file)
set(TEST_NAME "${src_file}_test")
add_executable(${TEST_NAME} ${src_file})

target_link_libraries(${TEST_NAME} PRIVATE GTest::gtest_main hSIM::defaults)
foreach(arg IN LISTS ARGN)
target_link_libraries(${TEST_NAME} PRIVATE ${arg})
endforeach()
gtest_discover_tests(
${TEST_NAME}
EXTRA_ARGS --gtest_color=yes
PROPERTIES LABELS unit)
endmacro()

add_subdirectory(hello)
1 change: 1 addition & 0 deletions test/unit/hello/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hsim_add_utest(hello.cc)
3 changes: 3 additions & 0 deletions test/unit/hello/hello.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <gtest/gtest.h>

TEST(Simple, Hello) { ASSERT_TRUE(true); }
14 changes: 14 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ CPMAddPackage(
GIT_TAG Release_3.12
EXCLUDE_FROM_ALL True
SYSTEM True)


# gtest
CPMAddPackage(
NAME
googletest
GITHUB_REPOSITORY
google/googletest
VERSION
1.16.0
OPTIONS
"INSTALL_GTEST OFF"
EXCLUDE_FROM_ALL True
SYSTEM True)