#--------------------------------------------
#
#         test components
#
#--------------------------------------------
camitk_application( NO_GUI
                    CEP_NAME SDK
                    ADDITIONAL_SOURCES CommandLineOptions.cxx CommandLineOptions.hxx
                    DESCRIPTION "Test application to load components and interact with them" 
)

# CDash subproject listing
set(CAMITK_TARGETS ${CAMITK_TARGETS} application-testcomponents CACHE INTERNAL "")

#---------------------------------
# Testing command-line robustness
#---------------------------------
set(TEST_BASENAME ${APPLICATION_TARGET_NAME})
camitk_init_test(${TEST_BASENAME})
# should pass because invoking testcomponents without arguments or with help arg shows usage and exit success
camitk_add_test(PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
camitk_add_test(EXECUTABLE_ARGS "--help" PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")
camitk_add_test(EXECUTABLE_ARGS "-h"     PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

# should pass because invoking testcomponents with a faulty arguments results in printing
# an "Argument error" message (and exit failure)
camitk_add_test(EXECUTABLE_ARGS "-badarg" 
                PASS_REGULAR_EXPRESSION "unknown option '-badarg'"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c missingtestfile" 
                PASS_REGULAR_EXPRESSION "Argument error: please provide a component test file to work with."
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c mycomponentextension -i missinglevel" 
                PASS_REGULAR_EXPRESSION "Argument error: please provide a valid test level"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c mycomponentextension -i anotherbadarg -badarg" 
                PASS_REGULAR_EXPRESSION "unknown option '-badarg'"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c mycomponentextension -i badlevel -l 0" 
                PASS_REGULAR_EXPRESSION "Argument error: please provide a valid test level"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c mycomponentextension -i badlevel -l 3" 
                PASS_REGULAR_EXPRESSION "Argument error: please provide a valid test level"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c mycomponentextension -i badcomponentfile -l 2" 
                PASS_REGULAR_EXPRESSION "Argument error: component test file \"badcomponentfile\" does not exist"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

camitk_add_test(EXECUTABLE_ARGS "-c badcomponentextension -i ${PROJECT_SOURCE_DIR}/sdk/components/vtkmesh/testdata/simple.vtk -l 2" 
                PASS_REGULAR_EXPRESSION "Argument error: component dll/so file \"badcomponentextension\" does not exist"
                PROJECT_NAME ${TEST_BASENAME} TEST_SUFFIX "-")

