Commits

Jose Luis Rivero  committed 11768fd Merge

Support for display testing macros

  • Participants
  • Parent commits 23cca4f, 627f043
  • Branches display-tests-fixed

Comments (0)

Files changed (3)

File cmake/GazeboUtils.cmake

   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,dynamic_lookup")
 endmacro()
 
+# This should be migrated to more fine control solution based on set_property APPEND
+# directories. It's present on cmake 2.8.8 while precise version is 2.8.7  
+link_directories(${PROJECT_BINARY_DIR}/test)
+include_directories("${PROJECT_SOURCE_DIR}/test/gtest/include")
+
 #################################################
+# Hack: extra sources to build binaries can be supplied to gz_build_tests in the variable
+#       GZ_BUILD_TESTS_EXTRA_EXE_SRCS. This variable will be clean up at the end of the function
 macro (gz_build_tests)
-
   # Build all the tests
   foreach(GTEST_SOURCE_file ${ARGN})
     string(REGEX REPLACE ".cc" "" BINARY_NAME ${GTEST_SOURCE_file})
-    add_executable(${BINARY_NAME} ${GTEST_SOURCE_file})
-
-    # This should be migrated to more fine control solution based on set_property APPEND
-    # directories. It's present on cmake 2.8.8 while precise version is 2.8.7  
-    include_directories("${PROJECT_SOURCE_DIR}/test/gtest/include")
+    add_executable(${BINARY_NAME} ${GTEST_SOURCE_file} ${GZ_BUILD_TESTS_EXTRA_EXE_SRCS})
 
     add_dependencies(${BINARY_NAME}
       gtest gtest_main
              ${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)
   endforeach()
 
+  set(GZ_BUILD_TESTS_EXTRA_EXE_SRCS "")
 endmacro()
 
 #################################################
-# INTERNAL function: do not call directly use gz_build_display_tests or gz_build_dri_tests
-macro (_gz_build_qt_tests)
-  # Build all the tests
-  foreach(QTEST_SOURCE_file ${ARGN})
-    string(REGEX REPLACE ".cc" "" BINARY_NAME ${QTEST_SOURCE_file})
-    string(REGEX REPLACE ".cc" ".hh" QTEST_HEADER_file ${QTEST_SOURCE_file})
-    QT4_WRAP_CPP(${BINARY_NAME}_MOC ${QTEST_HEADER_file} QTestFixture.hh)
 
-    add_executable(${BINARY_NAME}
+# Define GUI testing macros as empty and redefine them if support is found
+macro (gz_build_qt_tests)
+endmacro()
+macro (gz_build_display_tests)
+endmacro()
+macro (gz_build_dri_tests)
+endmacro()
+
+if (VALID_DISPLAY)
+  # Redefine build display tests
+  macro (gz_build_display_tests)
+    gz_build_tests(${ARGV})
+  endmacro()
+
+  # Redefine build qt tests
+  macro (gz_build_qt_tests)
+   # Build all the tests
+   foreach(QTEST_SOURCE_file ${ARGN})
+     string(REGEX REPLACE ".cc" "" BINARY_NAME ${QTEST_SOURCE_file})
+     string(REGEX REPLACE ".cc" ".hh" QTEST_HEADER_file ${QTEST_SOURCE_file})
+     QT4_WRAP_CPP(${BINARY_NAME}_MOC ${QTEST_HEADER_file} QTestFixture.hh)
+
+     add_executable(${BINARY_NAME}
       ${${BINARY_NAME}_MOC} ${QTEST_SOURCE_file} QTestFixture.cc)
 
     add_dependencies(${BINARY_NAME}
       ${QT_QTTEST_LIBRARY}
       ${QT_LIBRARIES}
       )
- 
+
     add_test(${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} -xml)
-  
+
     set_tests_properties(${BINARY_NAME} PROPERTIES TIMEOUT 240)
-  
-    # Check that the test produced a result and create a failure if it didn't.
-    # Guards against crashed and timed out tests.
-    add_test(check_${BINARY_NAME} ${PROJECT_SOURCE_DIR}/tools/check_test_ran.py
-             ${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)
-  endforeach()
-endmacro()
 
-# Define GUI testing macros as empty and redefine them if support is found
-macro (gz_build_display_tests)
-endmacro()
-macro (gz_build_dri_tests)
-endmacro()
+      # Check that the test produced a result and create a failure if it didn't.
+      # Guards against crashed and timed out tests.
+      add_test(check_${BINARY_NAME} ${PROJECT_SOURCE_DIR}/tools/check_test_ran.py
+               ${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)
+    endforeach()
+  endmacro()
+endif()
 
 if (VALID_DRI_DISPLAY)
   macro (gz_build_dri_tests)
-    _gz_build_qt_tests(${ARGV})
+    gz_build_tests(${ARGV})
   endmacro()
 endif()
-
-if (VALID_DISPLAY)
-  macro (gz_build_display_tests)
-    _gz_build_qt_tests(${ARGV})
-  endmacro()
-endif()
-
-

File gazebo/gui/CMakeLists.txt

   viewers/ViewFactory.hh
 )
 
-set (display_tests
+set (qt_tests 
   DataLogger_TEST.cc
   TimePanel_TEST.cc
   viewers/ImagesView_TEST.cc
 )
 
-# Generate executables for each of the QT unit tests
-gz_build_display_tests(${tests})
+gz_build_qt_tests(${qt_tests})
 
 set (resources resources.qrc)
 
+
 QT4_WRAP_CPP(headers_MOC ${qt_headers})
 QT4_ADD_RESOURCES(resources_RCC ${resources})
 
 gz_add_executable(gzclient ${sources} main.cc ${headers_MOC} ${headers} ${resources_RCC})
-
 gz_add_library(gazebo_gui ${sources} ${headers_MOC} ${headers} ${resources_RCC})
 
 add_dependencies(gazebo_gui gazebo_msgs)

File test/regression/CMakeLists.txt

   link_directories ( ${BULLET_LIBRARY_DIRS} )
 endif()
 
-include_directories(${PROJECT_SOURCE_DIR}/test/gtest/include)
+set(display_tests
+      bandwidth.cc
+      file_handling.cc
+      msgs.cc
+      physics.cc
+      server_fixture.cc
+      speed.cc
+      transport.cc)
 
-set (gtest_sources
-  bandwidth.cc
-  camera_sensor.cc
-  factory.cc
-  file_handling.cc
-  heightmap.cc
-  laser.cc
-  msgs.cc
-  physics.cc
-  pioneer2dx.cc
-  pr2.cc
-  projector.cc
-  server_fixture.cc
-  speed.cc
-  speed_pr2.cc
-  transport.cc)
+# Build the display tests (need extra sources to compile)
+set (GZ_BUILD_TESTS_EXTRA_EXE_SRCS
+    "${PROJECT_SOURCE_DIR}/gazebo/Server.cc;${PROJECT_SOURCE_DIR}/gazebo/Master.cc;${PROJECT_SOURCE_DIR}/gazebo/gazebo.cc")
+gz_build_display_tests(${display_tests})
 
-set (plugins)
+set(dri_tests
+      camera_sensor.cc
+      factory.cc
+      heightmap.cc
+      laser.cc
+      pioneer2dx.cc
+      pr2.cc
+      projector.cc
+      speed_pr2.cc)
 
-# Build plugins
-foreach (src ${plugins})
-  add_library(${src} SHARED ${src}.cc)
-  target_link_libraries(${src} libgazebo gazebo_sensors)
-endforeach (src ${plugins})
-
-# Build tests
-foreach(GTEST_SOURCE_file ${gtest_sources})
-  string(REGEX REPLACE ".cc" "" BINARY_NAME ${GTEST_SOURCE_file})
-  add_executable(${BINARY_NAME} ${GTEST_SOURCE_file} ${PROJECT_SOURCE_DIR}/gazebo/Server.cc ${PROJECT_SOURCE_DIR}/gazebo/Master.cc ${PROJECT_SOURCE_DIR}/gazebo/gazebo.cc)
-
-target_link_libraries(${BINARY_NAME}
-  ${GTEST_LIBRARY} 
-  ${GTEST_MAIN_LIBRARY} 
-    gazebo_common
-    gazebo_sdf_interface
-    gazebo_transport
-    gazebo_physics
-    gazebo_sensors
-    gazebo_rendering
-    gazebo_msgs
-    pthread
-    ${tinyxml_libraries}
-    )
-  add_test(${BINARY_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME} --gtest_output=xml:${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)
-  set_tests_properties(${BINARY_NAME} PROPERTIES TIMEOUT 240)
-  # Check that the test produced a result and create a failure if it didn't.
-  # Guards against crashed and timed out tests.
-  add_test(check_${BINARY_NAME} ${PROJECT_SOURCE_DIR}/tools/check_test_ran.py ${CMAKE_BINARY_DIR}/test_results/${BINARY_NAME}.xml)
-endforeach()
+set (GZ_BUILD_TESTS_EXTRA_EXE_SRCS
+    "${PROJECT_SOURCE_DIR}/gazebo/Server.cc;${PROJECT_SOURCE_DIR}/gazebo/Master.cc;${PROJECT_SOURCE_DIR}/gazebo/gazebo.cc")
+gz_build_dri_tests(${dri_tests})