diff --git a/.travis.yml b/.travis.yml index 7ed9a0680..cf218240d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ script: - mkdir build && cd build - cmake -DBOOST_ROOT=$BOOST_DIR -DSLIC3R_STATIC=ON ../src - cmake --build . + - ctest . branches: only: - master diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c7505067b..fea83f0a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -172,7 +172,9 @@ set(UI_TEST_SOURCES ${GUI_TESTDIR}/test_harness_gui.cpp ${GUI_TESTDIR}/test_field_checkbox.cpp ) - +set(SLIC3R_TEST_SOURCES + ${TESTDIR}/test_harness.cpp +) add_executable(slic3r slic3r.cpp) #set_target_properties(slic3r PROPERTIES LINK_SEARCH_START_STATIC 1) #set_target_properties(slic3r PROPERTIES LINK_SEARCH_END_STATIC 1) @@ -276,9 +278,8 @@ IF(wxWidgets_FOUND) target_compile_definitions(Catch INTERFACE $<$:_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING>) endif() add_executable(gui_test ${UI_TEST_SOURCES}) - add_test(NAME TestBase COMMAND gui_test) + add_test(NAME TestGUI COMMAND gui_test) target_link_libraries(gui_test PUBLIC libslic3r slic3r_gui Catch ${wxWidgets_LIBRARIES}) - endif() ELSE(wxWidgets_FOUND) # For convenience. When we cannot continue, inform the user @@ -306,7 +307,40 @@ IF (WIN32) ENDIF(WIN32) - +if (SLIC3R_BUILD_TESTS) + enable_testing() + if (NOT TARGET Catch) + include (ExternalProject) + if(IS_TRAVIS_BUILD) # on travis, use git for fetching instead of wget + set(FETCH_EXTERNAL_CATCH + GIT_REPOSITORY https://github.com/philsquared/Catch.git + GIT_TAG 19ab2117c5bac2f376f8da4a4b25e183137bcec0) + elseif(WIN32) + set(FETCH_EXTERNAL_CATCH + URL https://github.com/catchorg/Catch2/archive/v2.0.1.zip + URL_HASH MD5=1abca1b324b99b1631e999119b172620) + else() + set(FETCH_EXTERNAL_CATCH + URL https://github.com/catchorg/Catch2/archive/v2.0.1.tar.gz + URL_HASH MD5=2080f4696579351d9323b3b5a8c3c71b) + endif() + ExternalProject_Add(Catch-External + PREFIX ${CMAKE_BINARY_DIR}/external/Catch + ${FETCH_EXTERNAL_CATCH} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/external/Catch/src/Catch-External/single_include/catch.hpp + ${CMAKE_BINARY_DIR}/external/Catch/include/catch.hpp + ) + add_library(Catch INTERFACE) + add_dependencies(Catch Catch-External) + target_include_directories(Catch INTERFACE ${CMAKE_BINARY_DIR}/external/Catch/include) + target_compile_definitions(Catch INTERFACE $<$:_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING>) + endif() + add_executable(slic3r_test ${SLIC3R_TEST_SOURCES}) + add_test(NAME TestSlic3r COMMAND slic3r_test) + target_link_libraries(slic3r_test PUBLIC libslic3r Catch) +endif() diff --git a/src/test/GUI/test_field_checkbox.cpp b/src/test/GUI/test_field_checkbox.cpp index 23f275068..5453ee270 100644 --- a/src/test/GUI/test_field_checkbox.cpp +++ b/src/test/GUI/test_field_checkbox.cpp @@ -1,4 +1,4 @@ -#include "test/catch.hpp" +#include #ifndef WX_PRECOMP #include "wx/app.h" diff --git a/src/test/GUI/test_harness_gui.cpp b/src/test/GUI/test_harness_gui.cpp index fe8666f2d..3c3c6f2f5 100644 --- a/src/test/GUI/test_harness_gui.cpp +++ b/src/test/GUI/test_harness_gui.cpp @@ -1,2 +1,2 @@ #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file -#include "test/catch.hpp" +#include diff --git a/src/test/test_harness.cpp b/src/test/test_harness.cpp new file mode 100644 index 000000000..3c3c6f2f5 --- /dev/null +++ b/src/test/test_harness.cpp @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include