ソースを参照

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 年 前
コミット
eff5df41ba
共有2 個のファイルを変更した14 個の追加7 個の削除を含む
  1. 2 2
      Applications/ctkDICOMIndexer/Testing/Cpp/CMakeLists.txt
  2. 12 5
      Applications/ctkDICOMIndexer/Testing/Cpp/ctkDICOMIndexerTest1.cpp

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

@@ -1,7 +1,7 @@
 set(KIT ${PROJECT_NAME})
 
 create_test_sourcelist(Tests ${KIT}CppTests.cpp
-  ctkDICOMIndexerTest1.cpp
+  ctkDICOMIndexerAppTest1.cpp
   )
 
 SET (TestsToRun ${Tests})
@@ -17,4 +17,4 @@ target_link_libraries(${KIT}CppTests ${KIT_target_libraries})
 #
 # 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 <iostream>
 
-int ctkDICOMIndexerTest1(int argc, char * argv [])
+int ctkDICOMIndexerAppTest1(int argc, char * argv [])
 {
   QCoreApplication app(argc, argv);
   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;
   parameters << "--init" << database;
-  QString command = QString("ctkDICOMIndexer");
   int res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
     return res;
     }
@@ -46,7 +53,7 @@ int ctkDICOMIndexerTest1(int argc, char * argv [])
   res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
     return res;
     }
@@ -55,7 +62,7 @@ int ctkDICOMIndexerTest1(int argc, char * argv [])
   res = QProcess::execute(command, parameters);
   if (res != EXIT_SUCCESS)
     {
-    std::cerr << '\"' << qPrintable(command + parameters.join(" ")) << '\"'
+    std::cerr << '\"' << qPrintable(command + " " + parameters.join(" ")) << '\"'
               << " returned " << res << std::endl;
     return res;
     }