Commit d6e4549f authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

NEW command line argument tests

parent 4c448daf
......@@ -16,3 +16,46 @@ set(CAMITK_SUBPROJECTS ${CAMITK_SUBPROJECTS} application-testcomponents CACHE IN
#----------
# Define the application test component name
set( APPLICATION_TEST_COMPONENT ${APPLICATION_TARGET_NAME} CACHE INTERNAL "")# CACHE INTERNAL extends the scope of the variable outside the directory
#---------------------------------
# Testing command-line robustness
#---------------------------------
set(TEST_BASENAME ${APPLICATION_TARGET_NAME})
camitk_init_test(${APPLICATION_TARGET_NAME})
# should pass because invoking testcomponents without arguments shows usage and exit success
camitk_add_test(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 open."
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 "-")
......@@ -193,6 +193,7 @@ int main(int argc, char* argv[]) {
catch (const cli::exception& e) {
std::cerr << "testcomponents aborted due to invalid arguments: " << e.what() << "." << std::endl;
e.print(std::cerr);
std::cerr << std::endl;
return EXIT_FAILURE;
}
catch (const camitk::AbortException& e) {
......
Supports Markdown
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