Commit 53c4cd9d authored by Isaak Lim's avatar Isaak Lim
Browse files

It is now possible to provide run_single_object_file_mesh_test with an optional fourth argument,

which gives a directory with meshes for testing.
If a directory is given the TEST_FILE argument will be ignored.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14317 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c74b0b99
......@@ -9,7 +9,6 @@ if(BUILD_TESTING)
# Tests
# ========================================================================
# ========================================================================
run_single_object_file_mesh_test("fileskl" "Plugin-FileSKL/SkeletonWithAnimation.skl" "fileSkeletonTest.ofs")
run_single_object_file_mesh_test("fileskl" "Plugin-FileSKL/SkeletonWithoutAnimation.skl" "fileSkeletonTest.ofs")
run_single_object_file_mesh_test("fileskl" "" "fileSkeletonTest.ofs" ${_plugin_dir})
endif()
......@@ -9,66 +9,139 @@
# If that directory or file does not exist, no test will be generated!
#
# The third parameter is the script that will be used. It will be taken from the global tests directory
#
# An optional fourth parameter can be provided specifying a whole directory with meshes.
# The TEST_FILE will be ignored and tests will be run on the meshes in the given directory.
# For now the directory will not be traversed recursively.
# TODO: also take local scripts!
#
# Used files:
# fileMeshTest.ofs ( configured and copied script for meshes )
# run_file_test.cmake ( Executing the test and comparing the results)
function( run_single_object_file_mesh_test FILEPLUGIN TEST_FILE TEST_SCRIPT )
function( run_single_object_file_mesh_test FILEPLUGIN TEST_FILE TEST_SCRIPT )
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData)
return()
endif()
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE} )
return()
endif()
configure_file(${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE}
${OPENFLIPPER_TEST_FILES}/${TEST_FILE} COPYONLY)
# construct the testname from target test file and the plugin directory we are in
string (TOUPPER ${_plugin_dir} PLUGIN_DIR)
# replace possible forward slashes in TEST_FILE in order to avoid the creation
# of a new directory when the test script is configured
string (REPLACE "/" "-" TEST_FILE_NAME ${TEST_FILE})
set (TESTNAME "${PLUGIN_DIR}-${TEST_FILE_NAME}")
set (TESTSCRIPTNAME "testscript-${TESTNAME}-${TEST_SCRIPT}")
# update the output file to be inside the results directory
set (OUTPUT_TEST_DATA_FILE "${OPENFLIPPER_TEST_RESULTS}/${TESTSCRIPTNAME}-result.txt" )
# set file containing the information about the file to be checked
set (TEST_FILE_INFO ${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE}.info )
# Configure the test script from the current directory with the given filenames and variables into the test directory
configure_file(${CMAKE_SOURCE_DIR}/tests/${TEST_SCRIPT}
${CMAKE_BINARY_DIR}/tests/${_plugin_dir}/${TESTSCRIPTNAME} @ONLY )
# Execute the script by OpenFlipper and than run the result parser which checks for correct values.
set( test_cmd ${OPENFLIPPER_EXECUTABLE} )
set( args "-c -b ${TESTSCRIPTNAME}" )
add_test( ${TESTNAME}
${CMAKE_COMMAND}
-D test_cmd=${test_cmd}
-D test_args:string=${args}
-D output_test=${OUTPUT_TEST_DATA_FILE}
-D test_file_info=${TEST_FILE_INFO}
-D result_checker=${OPENFLIPPER_TEST_BINARIES}/compareTool
-P ${CMAKE_SOURCE_DIR}/tests/run_file_test.cmake
)
list( LENGTH ARGN opt_arg_length )
# handle a whole directory with test files
if ( opt_arg_length EQUAL 1 )
list(GET ARGN 0 dir)
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData/${dir} )
return()
endif()
# get the file ending (file type)
string( REPLACE "file" "" file_ending ${FILEPLUGIN} )
file( GLOB files ${CMAKE_SOURCE_DIR}/TestData/${dir}/*.${file_ending} )
foreach( testfile ${files} )
# get the file name
file( RELATIVE_PATH filename ${CMAKE_SOURCE_DIR}/TestData/${dir} ${testfile} )
configure_file(${CMAKE_SOURCE_DIR}/TestData/${dir}/${filename}
${OPENFLIPPER_TEST_FILES}/${dir}/${filename} COPYONLY)
# replace possible forward slashes in TEST_FILE in order to avoid the creation
# of a new directory when the test script is configured
string (REPLACE "/" "-" TEST_FILE_NAME ${filename})
set (TESTNAME "${PLUGIN_DIR}-${TEST_FILE_NAME}")
set (TESTSCRIPTNAME "testscript-${TESTNAME}-${TEST_SCRIPT}")
# update the output file to be inside the results directory
set (OUTPUT_TEST_DATA_FILE "${OPENFLIPPER_TEST_RESULTS}/${TESTSCRIPTNAME}-result.txt" )
# set file containing the information about the file to be checked
set (TEST_FILE_INFO ${testfile}.info )
set (TEST_FILE ${dir}/${filename})
# Configure the test script from the current directory with the given filenames and variables into the test directory
configure_file(${CMAKE_SOURCE_DIR}/tests/${TEST_SCRIPT}
${CMAKE_BINARY_DIR}/tests/${_plugin_dir}/${TESTSCRIPTNAME} @ONLY )
# Execute the script by OpenFlipper and than run the result parser which checks for correct values.
set( test_cmd ${OPENFLIPPER_EXECUTABLE} )
set( args "-c -b ${TESTSCRIPTNAME}" )
add_test( ${TESTNAME}
${CMAKE_COMMAND}
-D test_cmd=${test_cmd}
-D test_args:string=${args}
-D output_test=${OUTPUT_TEST_DATA_FILE}
-D test_file_info=${TEST_FILE_INFO}
-D result_checker=${OPENFLIPPER_TEST_BINARIES}/compareTool
-P ${CMAKE_SOURCE_DIR}/tests/run_file_test.cmake
)
# Timeout after 2 minutes if we have an endless loop
# Should be run serial to avoid collisons with other instances
# Only one processor required
set_tests_properties (
${TESTNAME} PROPERTIES
TIMEOUT 120
RUN_SERIAL TRUE
PROCESSORS 1
)
endforeach()
# handle a single test file
elseif( opt_arg_length EQUAL 0)
if ( NOT EXISTS ${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE} )
return()
endif()
configure_file(${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE}
${OPENFLIPPER_TEST_FILES}/${TEST_FILE} COPYONLY)
# replace possible forward slashes in TEST_FILE in order to avoid the creation
# of a new directory when the test script is configured
string (REPLACE "/" "-" TEST_FILE_NAME ${TEST_FILE})
set (TESTNAME "${PLUGIN_DIR}-${TEST_FILE_NAME}")
set (TESTSCRIPTNAME "testscript-${TESTNAME}-${TEST_SCRIPT}")
# update the output file to be inside the results directory
set (OUTPUT_TEST_DATA_FILE "${OPENFLIPPER_TEST_RESULTS}/${TESTSCRIPTNAME}-result.txt" )
# set file containing the information about the file to be checked
set (TEST_FILE_INFO ${CMAKE_SOURCE_DIR}/TestData/${TEST_FILE}.info )
# Configure the test script from the current directory with the given filenames and variables into the test directory
configure_file(${CMAKE_SOURCE_DIR}/tests/${TEST_SCRIPT}
${CMAKE_BINARY_DIR}/tests/${_plugin_dir}/${TESTSCRIPTNAME} @ONLY )
# Execute the script by OpenFlipper and than run the result parser which checks for correct values.
set( test_cmd ${OPENFLIPPER_EXECUTABLE} )
set( args "-c -b ${TESTSCRIPTNAME}" )
add_test( ${TESTNAME}
${CMAKE_COMMAND}
-D test_cmd=${test_cmd}
-D test_args:string=${args}
-D output_test=${OUTPUT_TEST_DATA_FILE}
-D test_file_info=${TEST_FILE_INFO}
-D result_checker=${OPENFLIPPER_TEST_BINARIES}/compareTool
-P ${CMAKE_SOURCE_DIR}/tests/run_file_test.cmake
)
# Timeout after 2 minutes if we have an endless loop
# Should be run serial to avoid collisons with other instances
# Only one processor required
set_tests_properties (
${TESTNAME} PROPERTIES
TIMEOUT 120
RUN_SERIAL TRUE
PROCESSORS 1
)
endif()
# Timeout after 2 minutes if we have an endless loop
# Should be run serial to avoid collisons with other instances
# Only one processor required
set_tests_properties (
${TESTNAME} PROPERTIES
TIMEOUT 120
RUN_SERIAL TRUE
PROCESSORS 1
)
endfunction()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment