Expanded tests slightly for config and laid out framework for external input files.

This commit is contained in:
Joseph Lenox 2018-07-12 11:08:15 -05:00
parent ff7ed5bd60
commit 8bac95a208
5 changed files with 35 additions and 1 deletions

View File

@ -67,9 +67,13 @@ find_package(Boost REQUIRED COMPONENTS system thread filesystem)
set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/../xs/src/) set(LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/../xs/src/)
set(GUI_LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/GUI/) set(GUI_LIBDIR ${CMAKE_CURRENT_SOURCE_DIR}/GUI/)
set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/test) set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
set(GUI_TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/test/GUI/) set(GUI_TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/test/GUI/)
# directory that contains the dependent non-source files, like models and configurations
set(TESTFILE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test/inputs/)
include_directories(${LIBDIR}) include_directories(${LIBDIR})
include_directories(${LIBDIR}/libslic3r) include_directories(${LIBDIR}/libslic3r)
include_directories(${LIBDIR}/slic3r/GUI/) include_directories(${LIBDIR}/slic3r/GUI/)
@ -376,11 +380,14 @@ if (SLIC3R_BUILD_TESTS)
target_include_directories(Catch INTERFACE ${CMAKE_BINARY_DIR}/external/Catch/include) target_include_directories(Catch INTERFACE ${CMAKE_BINARY_DIR}/external/Catch/include)
target_compile_definitions(Catch INTERFACE $<$<CXX_COMPILER_ID:MSVC>:_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING>) target_compile_definitions(Catch INTERFACE $<$<CXX_COMPILER_ID:MSVC>:_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING>)
endif() endif()
include_directories(${LIBDIR}/test)
configure_file("${LIBDIR}/test/test_options.hpp.in" "${LIBDIR}/test/test_options.hpp")
add_executable(slic3r_test ${SLIC3R_TEST_SOURCES}) add_executable(slic3r_test ${SLIC3R_TEST_SOURCES})
add_test(NAME TestSlic3r COMMAND slic3r_test) add_test(NAME TestSlic3r COMMAND slic3r_test)
target_link_libraries(slic3r_test PUBLIC libslic3r Catch ${LIBSLIC3R_DEPENDS}) target_link_libraries(slic3r_test PUBLIC libslic3r Catch ${LIBSLIC3R_DEPENDS})
endif() endif()
if (BUILD_EXTRUDE_TIN) if (BUILD_EXTRUDE_TIN)
target_link_libraries (extrude-tin libslic3r ${LIBSLIC3R_DEPENDS}) target_link_libraries (extrude-tin libslic3r ${LIBSLIC3R_DEPENDS})
endif() endif(

12
src/test/inputs/README.md Normal file
View File

@ -0,0 +1,12 @@
Directory containing test-specific input files that are not source code.
===
Rules
===
* Each folder shall be named for the test that it supports.
* `test_config` directory supports `test_config.cpp`, etc.
* If a specific test file is reused across multiple tests, it should go in the `common` directory.
* Each extra input file should be named in such a way that it is relevant to the specific feature of it.
* No files should have special characters in the name (unless those special characters are part of the test).
* No spaces should be in the file paths (again, unless testing the presence of spaces is part of the test).

View File

@ -1,8 +1,12 @@
#include <catch.hpp> #include <catch.hpp>
#include "Config.hpp" #include "Config.hpp"
#include <test_paths.hpp>
#include <string>
using namespace Slic3r; using namespace Slic3r;
using namespace std::string_literals;
SCENARIO("Generic config validation performs as expected.", "[!mayfail]") { SCENARIO("Generic config validation performs as expected.", "[!mayfail]") {
GIVEN("A config generated from default options") { GIVEN("A config generated from default options") {
@ -96,5 +100,10 @@ SCENARIO("Config accessor functions perform as expected.", "[!mayfail]") {
} }
SCENARIO("Config ini load/save interface", "[!mayfail]") { SCENARIO("Config ini load/save interface", "[!mayfail]") {
WHEN("new_from_ini is called") {
auto config {Slic3r::Config::new_from_config(std::string(testfile_dir) + "test_config/new_from_ini.ini"s) };
THEN("Config object contains ini file options.") {
}
}
REQUIRE(false); REQUIRE(false);
} }

View File

@ -0,0 +1,6 @@
#ifndef TEST_OPTIONS_HPP
/// Directory path, passed in from the outside, for the path to the test inputs dir.
constexpr auto* testfile_dir {U"@TESTFILE_DIR@"};
#endif // TEST_OPTIONS_HPP