Commit b53d7c3f authored by lealv's avatar lealv
Browse files

UPDATED - CTEST - TestActions: provide the option in CMakeLists.txt to give...

UPDATED - CTEST - TestActions: provide the option in CMakeLists.txt to give the name of the files to be tested.




git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1849 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 9136e5ad
......@@ -31,6 +31,7 @@
#! [TEST_APPLICATION application-name]
#! [DESCRIPTION description]
#! [EXTRA_TRANSLATE_LANGUAGE]
#! [TEST_FILES file1 file2 ...]
#! )
#! \endcode
#!
......@@ -71,6 +72,7 @@
#! \param TEST_APPLICATION = The name of the application to provide for generate automatic basic tests on your extension. No option means no tests!
#! \param DESCRIPTION = Simple description of the extension. Used for packaging presentation for instance.
#! \param EXTRA_TRANSLATE_LANGUAGE = Additionnal extra language to translate the application
#! \param TEST_FILES = Parameter of TestActions module : REQUIRED. List of files on which the action must applied.
macro(camitk_extension)
......@@ -86,7 +88,7 @@ macro(camitk_extension)
get_directory_name(${CMAKE_CURRENT_SOURCE_DIR} EXTENSION_NAME)
parse_arguments(${EXTENSION_NAME_CMAKE} #prefix
"NEEDS_TOOL;NEEDS_CEP_LIBRARIES;NEEDS_COMPONENT_EXTENSION;NEEDS_ACTION_EXTENSION;INCLUDE_DIRECTORIES;EXTERNAL_LIBRARIES;HEADERS_TO_INSTALL;DEFINES;CXX_FLAGS;EXTERNAL_SOURCES;TARGET_NAME;CEP_NAME;DESCRIPTION;TEST_APPLICATION;EXTRA_TRANSLATE_LANGUAGE" # possible lists
"NEEDS_TOOL;NEEDS_CEP_LIBRARIES;NEEDS_COMPONENT_EXTENSION;NEEDS_ACTION_EXTENSION;INCLUDE_DIRECTORIES;EXTERNAL_LIBRARIES;HEADERS_TO_INSTALL;DEFINES;CXX_FLAGS;EXTERNAL_SOURCES;TARGET_NAME;CEP_NAME;DESCRIPTION;TEST_APPLICATION;EXTRA_TRANSLATE_LANGUAGE;TEST_FILES" # possible lists
"NEEDS_QT_MODULES;ACTION_EXTENSION;COMPONENT_EXTENSION;DISABLED;NEEDS_XERCESC;NEEDS_ITK;NEEDS_LIBXML2;NEEDS_XSD;NEEDS_QTXML;NEEDS_OPENCV;NEEDS_IGSTK;INSTALL_ALL_HEADERS;NEEDS_GDCM;DISABLE_TESTLEVEL1;DISABLE_TESTLEVEL2;DISABLE_TESTLEVEL3" # possible options
${ARGN}
)
......@@ -1466,28 +1468,25 @@ macro(camitk_extension)
get_directory_name( ${CMAKE_CURRENT_SOURCE_DIR} COMP_DIR_NAME )
# Test should pass because application test runs with no arguments - shows usage and exit success
camitk_add_test( TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
# Retrieve the files in ctestdata directory - tests will be applied for each of these files
get_subdirectoryfiles( ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata TESTFILES )
camitk_add_test( TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
#get the names of actions .dlls in lib directory
get_subdirectoryfiles( ${CAMITK_BUILD_PRIVATE_LIB_DIR}/actions/ ACTIONSDLLS )
foreach( ACTION_TESTDATA_FILE ${TESTFILES} )
# Give the file name (full path cut)
get_directory_name( ${ACTION_TESTDATA_FILE} DATA_FILE )
if( NOT ( ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME} MATCHES "application" ) )#We do not apply tests on actions like (close, save, save as)
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
if(MSVC)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
elseif(APPLE)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dylib" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
elseif(UNIX)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.so" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
endif()
camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 3 DESCRIPTION "Open a file, load the action and apply it on the component.")
endif()
foreach( ACTION_TESTDATA_FILE ${${EXTENSION_NAME_CMAKE}_TEST_FILES} )
message( STATUS "Action extension: " ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME} " Test file: " ${ACTION_TESTDATA_FILE} )
if( NOT ( ${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME} MATCHES "application" ) )#We do not apply tests on actions like (close, save, save as)
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
if(MSVC)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
elseif(APPLE)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dylib" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
elseif(UNIX)
camitk_add_test( EXECUTABLE_ARGS "-i ${CAMITK_BUILD_TESTDATA_DIR}/ctestdata/${DATA_FILE} -a lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.so" TEST_SUFFIX ${COMP_DIR_NAME} PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME} )
endif()
camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 3 DESCRIPTION "Open a file, load the action and apply it on the component.")
endif()
endforeach()
endif()
endif() # endif(${TYPE_EXTENSION_CMAKE}_${EXTENSION_NAME_CMAKE})
......
......@@ -65,11 +65,11 @@ int main(int argc, char *argv[]) {
|| (o.input() == "" && o.action() == "")
)
{
std::cout << "Help or no arguments: ";
std::cout << "Help or no arguments: " << std::endl;
usage(argv[0]);
}
else if( o.input() == "" || o.action() == "" ) {
std::cout << "Bad arguments: ";
std::cout << "Bad arguments: " << std::endl;
usage(argv[0]);
}
else
......@@ -82,8 +82,8 @@ int main(int argc, char *argv[]) {
// avoid all redirection to console
MainWindow *defaultMainWindow = dynamic_cast<MainWindow*>(a.getMainWindow());
defaultMainWindow->redirectToConsole(false);
// Remember, autoload search for extension dynamic libraries in the lib/actions and lib/components subdirectories of
// Remember, autoload search for extension dynamic libraries in the lib/actions and lib/components subdirectories of
// the following trees:
// * current working directory (build)
// * local installation
......@@ -96,26 +96,29 @@ int main(int argc, char *argv[]) {
if( comp )
{
std::cout << "Component loaded: " << o.input() << std::endl;
std::cout << "Component loaded: " << o.input() << std::endl;
Action::ApplyStatus status;
comp->setSelected( true, true );
// Find the actions directory, according to this application's location
// If the application directory is in the build/bin directory, then the action directory will point on the build/lib/camitk-version/actions directory
// Note : do not use Core::getActionDirectories as it uses Core::getCurrentWorkingDir which is clearly less accurate
QString actionsDirectory = Application::instance()->applicationDirPath() + "/../lib/" + Core::shortVersion + "/actions/";
// If the application directory is in the build/bin directory, then the action directory will point on the build/lib/camitk-version/actions directory
// Note : do not use Core::getActionDirectories as it uses Core::getCurrentWorkingDir which is clearly less accurate
QString actionsDirectory = Application::instance()->applicationDirPath() + "/../lib/" + Core::shortVersion + "/actions/";
//Load the action extension defined in the entry parameters
if (!(actionsDirectory.isEmpty())
&& (ExtensionManager::loadExtension(ExtensionManager::ACTION, actionsDirectory + o.action().data())))
if (!(actionsDirectory.isEmpty())
&& (ExtensionManager::loadExtension(ExtensionManager::ACTION, actionsDirectory + o.action().data())))
{
std::cout << "load action extension "<< o.action().data() << std::endl;
ActionList actl = Application::getActions( comp );
if( !( actl.isEmpty() ))
{
std::cout << "Action list is not empty. " << std::endl;
foreach( Action *action , actl )
{
std::cout << "Test action " << action->getName().toStdString() << std::endl;
action->setInputComponent( comp );
std::cout << action->getName().toStdString() << " call apply() " << std::endl;
status = action->apply();
if( status != Action::SUCCESS )
......@@ -162,5 +165,4 @@ int main(int argc, char *argv[]) {
std::cout << argv[0] << " aborted..." << std::endl << "Unknown Exception" << std::endl;
return EXIT_FAILURE;
}
}
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