Просмотр исходного кода

Fix dicom indexer test and change duplicated test name

Avoid duplicated name with lib test.

Also pass the actual path to the executable into the test so that
it will work correctly (thanks Jc for the cmake magic words!).
Steve Pieper лет назад: 12
Родитель
Сommit
eff5df41ba

+ 2 - 2
Applications/ctkDICOMIndexer/Testing/Cpp/CMakeLists.txt

@@ -1,7 +1,7 @@
 set(KIT ${PROJECT_NAME})
 set(KIT ${PROJECT_NAME})
 
 
 create_test_sourcelist(Tests ${KIT}CppTests.cpp
 create_test_sourcelist(Tests ${KIT}CppTests.cpp
-  ctkDICOMIndexerTest1.cpp
+  ctkDICOMIndexerAppTest1.cpp
   )
   )
 
 
 SET (TestsToRun ${Tests})
 SET (TestsToRun ${Tests})
@@ -17,4 +17,4 @@ target_link_libraries(${KIT}CppTests ${KIT_target_libraries})
 #
 #
 # Add Tests
 # Add Tests
 #
 #
-SIMPLE_TEST( ctkDICOMIndexerTest1 )
+SIMPLE_TEST( ctkDICOMIndexerAppTest1 $<TARGET_FILE:ctkDICOMIndexer> )

+ 12 - 5
Applications/ctkDICOMIndexer/Testing/Cpp/ctkDICOMIndexerTest1.cpp

@@ -26,18 +26,25 @@
 #include <cstdlib>
 #include <cstdlib>
 #include <iostream>
 #include <iostream>
 
 
-int ctkDICOMIndexerTest1(int argc, char * argv [])
+int ctkDICOMIndexerAppTest1(int argc, char * argv [])
 {
 {
   QCoreApplication app(argc, argv);
   QCoreApplication app(argc, argv);
   QString database("test.db");
   QString database("test.db");
 
 
+  if (argc < 2)
+    {
+    std::cerr << "Must specify path to ctkDICOMIndexer on command line\n";
+    return EXIT_FAILURE;
+    }
+  std::cout << "Testing ctkDICOMIndexer: " << argv[1] << "\n";
+  QString command = QString(argv[1]);
+
   QStringList parameters;
   QStringList parameters;
   parameters << "--init" << database;
   parameters << "--init" << database;
-  QString command = QString("ctkDICOMIndexer");
   int res = QProcess::execute(command, parameters);
   int res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
   if (res != EXIT_SUCCESS)
     {
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
               << " returned " << res << std::endl;
     return res;
     return res;
     }
     }
@@ -46,7 +53,7 @@ int ctkDICOMIndexerTest1(int argc, char * argv [])
   res = QProcess::execute(command, parameters);
   res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
   if (res != EXIT_SUCCESS)
     {
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
               << " returned " << res << std::endl;
     return res;
     return res;
     }
     }
@@ -55,7 +62,7 @@ int ctkDICOMIndexerTest1(int argc, char * argv [])
   res = QProcess::execute(command, parameters);
   res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
   if (res != EXIT_SUCCESS)
     {
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
               << " returned " << res << std::endl;
     return res;
     return res;
     }
     }