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

github action tests #23

Merged
merged 4 commits into from
Oct 12, 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
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
branches:
- main
pull_request:

jobs:
test:
name: C++ Tests
runs-on: ubuntu-latest

steps:
- name: Install Cmake
run: sudo apt install cmake

- name: Checkout Repo
uses: actions/checkout@v2
with:
submodules: true
token: ${{ secrets.SSH_TOKEN }}

- name: Set up Cmake
run: cmake .

- name: Run tests
run: make test



25 changes: 2 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,6 @@ target_link_libraries(obcpp
# =============================
# Unit tests

add_subdirectory(tests)
add_subdirectory(deps/google-test)

# enable CTest testing
enable_testing()

# Add a testing executable
add_executable(hello_test tests/hello_test.cpp)
add_executable(hello_test2 tests/hello_test2.cpp)

target_link_libraries(
hello_test
GTest::GTest
GTest::Main
)

target_link_libraries(
hello_test2
GTest::GTest
GTest::Main
)

add_test(test_all ./bin/hello_test)
add_test(test_all ./bin/hello_test2)
# =============================
# =============================
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Now that everything is installed, here is the process to build and run the appli

11. Verify that the testing framework is set up correctly
```sh
ctest .
make test
```

If you receive output about certain tests passing/failing, then you are good. Ideally the main branch (which should be what
Expand All @@ -130,4 +130,4 @@ Each module has its own folder in `include/` and `src/`. Currently all of the he

## Style

We are still deciding on a linting/style pipeline. When this is decided, this section should be updated.
We are still deciding on a linting/style pipeline. When this is decided, this section should be updated.
21 changes: 21 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(BINARY ${CMAKE_PROJECT_NAME}_tests)

file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false *.h *.cpp)

set(SOURCES ${TEST_SOURCES})

add_executable(${BINARY} ${TEST_SOURCES})

target_link_libraries(${BINARY} PUBLIC gtest_main)

add_test(NAME ${BINARY} COMMAND ${BINARY})

# setup make target (make test)
add_custom_target(test)
add_custom_command(
TARGET test
COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${BINARY}"
ARGS "--output-on-failure"
)
add_dependencies(test ${BINARY})

2 changes: 1 addition & 1 deletion tests/hello_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
TEST(HelloTest, HelloTest1) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
Expand Down
3 changes: 1 addition & 2 deletions tests/hello_test2.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <gtest/gtest.h>

// Demonstrate some basic assertions.
TEST(HelloTest, BasicAssertions) {
TEST(HelloTest, HelloTest2) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
EXPECT_LT(3, 8);
}

Loading