diff --git a/.github/workflows/linux_check.yml b/.github/workflows/linux_check.yml new file mode 100644 index 0000000..efd0549 --- /dev/null +++ b/.github/workflows/linux_check.yml @@ -0,0 +1,22 @@ +name: CI for Linux + +on: push + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: build + run: | + mkdir build && cd build + cmake ../src + make + cd .. + - name: regression test + run: | + cd tests + pwd + ls -l + ./run_tests.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34d4e07..e12911c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,12 +21,17 @@ project("datalog-cpp") # specify the C++ standard set(CMAKE_CXX_STANDARD 17) +# unit-test library +add_library(tests_main STATIC ../tests/tests_main.cpp) + # types_test target add_executable(types_test ../tests/types_test.cpp) target_include_directories(types_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(types_test tests_main) target_compile_definitions(types_test PUBLIC UNIX) # variable_test target add_executable(variable_test ../tests/variable_test.cpp) target_include_directories(variable_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(variable_test tests_main) target_compile_definitions(variable_test PUBLIC UNIX) diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..d5b72c4 --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e +../build/types_test +../build/variable_test \ No newline at end of file diff --git a/tests/tests_main.cpp b/tests/tests_main.cpp new file mode 100644 index 0000000..8daed99 --- /dev/null +++ b/tests/tests_main.cpp @@ -0,0 +1,3 @@ +// tests-main.cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" \ No newline at end of file diff --git a/tests/types_test.cpp b/tests/types_test.cpp index 91ab821..7d7f9be 100644 --- a/tests/types_test.cpp +++ b/tests/types_test.cpp @@ -1,6 +1,3 @@ -// Let Catch provide main(): -#define CATCH_CONFIG_MAIN - #include "catch.hpp" #include "Datalog.h" diff --git a/tests/variable_test.cpp b/tests/variable_test.cpp index c5b82ec..0b9c525 100644 --- a/tests/variable_test.cpp +++ b/tests/variable_test.cpp @@ -1,6 +1,3 @@ -// Let Catch provide main(): -#define CATCH_CONFIG_MAIN - #include "catch.hpp" #include "Variable.h" @@ -18,9 +15,9 @@ bool boundVariableTest() { } TEST_CASE( "An new variable is unbound", "[variable]" ) { - REQUIRE( freeVariableTest() ); + REQUIRE( freeVariableTest() == true ); } TEST_CASE( "A variable with a value is bound", "[variable]" ) { - REQUIRE( freeVariableTest() ); + REQUIRE( boundVariableTest() == true ); }