From e3668d21c9113b0d84d8711ef70cb8fce5be8d8a Mon Sep 17 00:00:00 2001 From: Ian Wright Date: Tue, 28 Apr 2020 14:48:12 +0100 Subject: [PATCH 1/3] minimise test compilation time; add test script and actions CI file --- .github/workflows/linux_check.yml | 22 ++++++++++++++++++++++ src/CMakeLists.txt | 5 +++++ tests/run_tests.sh | 4 ++++ tests/tests_main.cpp | 3 +++ tests/types_test.cpp | 3 --- tests/variable_test.cpp | 3 --- 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/linux_check.yml create mode 100755 tests/run_tests.sh create mode 100644 tests/tests_main.cpp 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..e00789e 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" From 406406112bc123ab7405ca197fcfc82143af81ac Mon Sep 17 00:00:00 2001 From: Ian Wright Date: Tue, 28 Apr 2020 14:52:05 +0100 Subject: [PATCH 2/3] test CI --- tests/variable_test.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/variable_test.cpp b/tests/variable_test.cpp index e00789e..51851b5 100644 --- a/tests/variable_test.cpp +++ b/tests/variable_test.cpp @@ -11,13 +11,15 @@ bool freeVariableTest() { bool boundVariableTest() { Variable intVar; intVar.bind(0); - return intVar.isBound(); + // break this + //return intVar.isBound(); + return !intVar.isBound(); } 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 ); } From 66ab130d9153ff18ff1591f061571628c22221e8 Mon Sep 17 00:00:00 2001 From: Ian Wright Date: Tue, 28 Apr 2020 14:54:04 +0100 Subject: [PATCH 3/3] fix regression test --- tests/variable_test.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/variable_test.cpp b/tests/variable_test.cpp index 51851b5..0b9c525 100644 --- a/tests/variable_test.cpp +++ b/tests/variable_test.cpp @@ -11,9 +11,7 @@ bool freeVariableTest() { bool boundVariableTest() { Variable intVar; intVar.bind(0); - // break this - //return intVar.isBound(); - return !intVar.isBound(); + return intVar.isBound(); } TEST_CASE( "An new variable is unbound", "[variable]" ) {