Make glfw auto-terminate during testing

The UnitTestMapperGLFW test was coded to run in an interactive mode,
which was problematic when simply running the test. If no one was there
to exit the interactive window, the test would time out. This change
adds a "batch" mode that is on when run by ctest. The batch mode runs
through all configurations and exits.
This commit is contained in:
Kenneth Moreland 2016-08-26 08:28:35 -06:00
parent b568dcee62
commit 4fd9ba7e11
3 changed files with 25 additions and 7 deletions

@ -241,11 +241,12 @@ endfunction(vtkm_pyexpander_generated_file)
# vtkm_unit_tests(
# SOURCES <source_list>
# LIBRARIES <dependent_library_list>
# TEST_ARGS <argument_list>
# )
function(vtkm_unit_tests)
set(options CUDA)
set(oneValueArgs)
set(multiValueArgs SOURCES LIBRARIES)
set(multiValueArgs SOURCES LIBRARIES TEST_ARGS)
cmake_parse_arguments(VTKm_UT
"${options}" "${oneValueArgs}" "${multiValueArgs}"
${ARGN}
@ -307,7 +308,7 @@ function(vtkm_unit_tests)
foreach (test ${VTKm_UT_SOURCES})
get_filename_component(tname ${test} NAME_WE)
add_test(NAME ${tname}
COMMAND ${test_prog} ${tname}
COMMAND ${test_prog} ${tname} ${VTKm_UT_TEST_ARGS}
)
set_tests_properties("${tname}" PROPERTIES TIMEOUT ${timeout})
endforeach (test)

@ -21,8 +21,11 @@
vtkm_configure_component_GLFW()
if (VTKm_GLFW_FOUND)
set(unit_tests
UnitTestMapperGLFW.cxx
)
VTKm_unit_tests(SOURCES ${unit_tests})
UnitTestMapperGLFW.cxx
)
VTKm_unit_tests(
SOURCES ${unit_tests}
TEST_ARGS -B
)
endif()

@ -33,6 +33,7 @@ namespace {
static const vtkm::Id WIDTH = 512, HEIGHT = 512;
static vtkm::Id which = 0, NUM_DATASETS = 4;
static bool done = false;
static bool batch = false;
static void
keyCallback(GLFWwindow* vtkmNotUsed(window), int key,
@ -78,13 +79,26 @@ void RenderTests()
vtkm::rendering::testing::Render<M,C,V2>(maker.Make2DRectilinearDataSet0(),
"pointvar", colorTable, "rect2D.pnm");
glfwSwapBuffers(window);
if (batch)
{
which++;
if (which >= NUM_DATASETS) { break; }
}
}
glfwDestroyWindow(window);
}
} //namespace
int UnitTestMapperGLFW(int, char *[])
int UnitTestMapperGLFW(int argc, char *argv[])
{
return vtkm::cont::testing::Testing::Run(RenderTests);
if (argc > 1)
{
if (strcmp(argv[1], "-B") == 0)
{
batch = true;
}
}
return vtkm::cont::testing::Testing::Run(RenderTests);
}