Sfoglia il codice sorgente

fix to run unittests in their source directory for potentially local files being used

Johannes Ruehle 11 anni fa
parent
commit
4a6de96048
2 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 2 1
      CMakeLists.txt
  2. 4 1
      cmake/NiceModules.cmake

+ 2 - 1
CMakeLists.txt

@@ -1,4 +1,5 @@
-cmake_minimum_required(VERSION 2.8.6) #version 2.8.6 at least required because of command set(CMAKE_AUTOMOC TRUE) for qt moc-ing (see below)
+#cmake_minimum_required(VERSION 2.8.6) #version 2.8.6 at least required because of command set(CMAKE_AUTOMOC TRUE) for qt moc-ing (see below)
+cmake_minimum_required(VERSION 2.8.12) #version 2.8.12 at least required because of command  get_filename_component(__testname_dir ${__testname_abspath} DIRECTORY) (getting directory path of filename)
 project (NICELibrary)
 
 include(CheckSymbolExists)

+ 4 - 1
cmake/NiceModules.cmake

@@ -65,6 +65,9 @@ macro(nice_add_unittests)
     message(STATUS "building tests:")
     foreach(__testcpp ${nice_${the_library}_TESTFILES_SRC})
       get_filename_component(__testname ${__testcpp} NAME_WE )
+      nice_get_real_path(__testname_abspath ${__testcpp})
+      get_filename_component(__testname_dir ${__testname_abspath} DIRECTORY)
+
       message(STATUS "unittest: ${__testname} ${__testcpp}")
       
       ADD_EXECUTABLE( ${__testname} ../templates/cppUnitTestRunner.cpp ${__testcpp})
@@ -72,7 +75,7 @@ macro(nice_add_unittests)
 
       INSTALL(TARGETS ${__testname} DESTINATION "tests/${the_library}")
       SET_PROPERTY(TARGET ${__testname} PROPERTY FOLDER "unittests/${the_library}")
-      ADD_TEST(${__testname} ${__testname})
+      ADD_TEST(${__testname} ${__testname} WORKING_DIRECTORY ${__testname_dir})
     endforeach()
 
 #     INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})