diff options
author | Paul Oppenheim <poppy@lindenlab.com> | 2009-06-19 23:24:11 +0000 |
---|---|---|
committer | Paul Oppenheim <poppy@lindenlab.com> | 2009-06-19 23:24:11 +0000 |
commit | 351ebe9fcb76f3b99c2957004bb8493a904869ee (patch) | |
tree | 611a8bc735d719e8ba742c65614dd99634982b9c | |
parent | c90c3630ab5c4d002c5c9b0034d19f0d10b1ceff (diff) |
result of "svn merge -r123757:124890 svn+ssh://svn.lindenlab.com/svn/linden/branches/improve-unit-testing/iface-04" for QAR-1496
-rw-r--r-- | indra/cmake/LLAddBuildTest.cmake | 276 | ||||
-rwxr-xr-x | indra/develop.py | 4 | ||||
-rw-r--r-- | indra/llcommon/CMakeLists.txt | 9 | ||||
-rw-r--r-- | indra/llmath/CMakeLists.txt | 9 | ||||
-rw-r--r-- | indra/llmessage/CMakeLists.txt | 13 | ||||
-rw-r--r-- | indra/newview/CMakeLists.txt | 20 |
6 files changed, 180 insertions, 151 deletions
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake index 08151bc732..4a61725e09 100644 --- a/indra/cmake/LLAddBuildTest.cmake +++ b/indra/cmake/LLAddBuildTest.cmake @@ -1,154 +1,150 @@ # -*- cmake -*- -INCLUDE(APR) -INCLUDE(LLMath) - -MACRO(ADD_BUILD_TEST_NO_COMMON name parent) -# MESSAGE("${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") - IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") - SET(no_common_libraries - ${APRUTIL_LIBRARIES} - ${APR_LIBRARIES} - ${PTHREAD_LIBRARY} - ${WINDOWS_LIBRARIES} - ) - SET(no_common_source_files - ${name}.cpp - tests/${name}_test.cpp - ${CMAKE_SOURCE_DIR}/test/test.cpp - ) - ADD_BUILD_TEST_INTERNAL("${name}" "${parent}" "${no_common_libraries}" "${no_common_source_files}") - ENDIF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") -ENDMACRO(ADD_BUILD_TEST_NO_COMMON name parent) - - -MACRO(ADD_BUILD_TEST name parent) - # optional extra parameter: list of additional source files - SET(more_source_files "${ARGN}") - -# MESSAGE("${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") - IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") - - SET(basic_libraries - ${LLCOMMON_LIBRARIES} - ${APRUTIL_LIBRARIES} - ${APR_LIBRARIES} - ${PTHREAD_LIBRARY} - ${WINDOWS_LIBRARIES} - ) - SET(basic_source_files - ${name}.cpp - tests/${name}_test.cpp - ${CMAKE_SOURCE_DIR}/test/test.cpp - ${CMAKE_SOURCE_DIR}/test/lltut.cpp - ${more_source_files} - ) - ADD_BUILD_TEST_INTERNAL("${name}" "${parent}" "${basic_libraries}" "${basic_source_files}") - - ENDIF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/${name}_test.cpp") -ENDMACRO(ADD_BUILD_TEST name parent) - - -MACRO(ADD_VIEWER_BUILD_TEST name parent) - # This is just like the generic ADD_BUILD_TEST, but we implicitly - # add the necessary precompiled header .cpp file (anyone else find that - # oxymoronic?) because the MSVC build errors will NOT point you there. - ADD_BUILD_TEST("${name}" "${parent}" llviewerprecompiledheaders.cpp) -ENDMACRO(ADD_VIEWER_BUILD_TEST name parent) - - -MACRO(ADD_SIMULATOR_BUILD_TEST name parent) - ADD_BUILD_TEST("${name}" "${parent}" llsimprecompiledheaders.cpp) - - if (WINDOWS) - SET_SOURCE_FILES_PROPERTIES( - "tests/${name}_test.cpp" - PROPERTIES - COMPILE_FLAGS "/Yullsimprecompiledheaders.h" - ) - endif (WINDOWS) -ENDMACRO(ADD_SIMULATOR_BUILD_TEST name parent) - -MACRO(ADD_BUILD_TEST_INTERNAL name parent libraries source_files) - # Optional additional parameter: pathname of Python wrapper script - SET(wrapper "${ARGN}") - #MESSAGE(STATUS "ADD_BUILD_TEST_INTERNAL ${name} wrapper = ${wrapper}") - - SET(TEST_SOURCE_FILES ${source_files}) - SET(HEADER "${name}.h") - set_source_files_properties(${HEADER} - PROPERTIES HEADER_FILE_ONLY TRUE) - LIST(APPEND TEST_SOURCE_FILES ${HEADER}) - INCLUDE_DIRECTORIES("${LIBS_OPEN_DIR}/test") - ADD_EXECUTABLE(${name}_test ${TEST_SOURCE_FILES}) - TARGET_LINK_LIBRARIES(${name}_test - ${libraries} - ) - - GET_TARGET_PROPERTY(TEST_EXE ${name}_test LOCATION) - SET(TEST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}_test_ok.txt) - - IF ("${wrapper}" STREQUAL "") - SET(TEST_CMD ${TEST_EXE} --touch=${TEST_OUTPUT} --sourcedir=${CMAKE_CURRENT_SOURCE_DIR}) - ELSE ("${wrapper}" STREQUAL "") - SET(TEST_CMD ${PYTHON_EXECUTABLE} ${wrapper} ${TEST_EXE} --touch=${TEST_OUTPUT} --sourcedir=${CMAKE_CURRENT_SOURCE_DIR}) - ENDIF ("${wrapper}" STREQUAL "") - - #MESSAGE(STATUS "ADD_BUILD_TEST_INTERNAL ${name} test_cmd = ${TEST_CMD}") +MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources) + # Given a project name and a list of sourcefiles (with optional properties on each), + # add targets to build and run the tests specified. + # ASSUMPTIONS: + # * this macro is being executed in the project file that is passed in + # * current working SOURCE dir is that project dir + # * there is a subfolder tests/ with test code corresponding to the filenames passed in + # * properties for each sourcefile passed in indicate what libs to link that file with (MAKE NO ASSUMPTIONS ASIDE FROM TUT) + # + # More info and examples at: https://wiki.secondlife.com/wiki/How_to_add_unit_tests_to_indra_code + # + # WARNING: do NOT modify this code without working with poppy or daveh - + # there is another branch that will conflict heavily with any changes here. + + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} sources: ${sources}") + ENDIF(LL_TEST_VERBOSE) + + # Start with the header and project-wide setup before making targets + #project(UNITTEST_PROJECT_${project}) + # Setup includes, paths, etc + SET(alltest_SOURCE_FILES + ${CMAKE_SOURCE_DIR}/test/test.cpp + ) + SET(alltest_DEP_TARGETS + llcommon + llmath + ) + SET(alltest_INCLUDE_DIRS + ${LLMATH_INCLUDE_DIRS} + ${LLCOMMON_INCLUDE_DIRS} + ${LIBS_OPEN_DIR}/test + ) + SET(alltest_LIBRARIES + ${PTHREAD_LIBRARY} + ${WINDOWS_LIBRARIES} + ) + # Headers, for convenience in targets. + SET(alltest_HEADER_FILES + ${CMAKE_SOURCE_DIR}/test/test.h + ) + + # start the source test executable definitions + SET(${project}_TEST_OUTPUT "") + FOREACH (source ${sources}) + STRING( REGEX REPLACE "(.*)\\.[^.]+$" "\\1" name ${source} ) + STRING( REGEX REPLACE ".*\\.([^.]+)$" "\\1" extension ${source} ) + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} individual source: ${source} (${name}.${extension})") + ENDIF(LL_TEST_VERBOSE) + + # + # Per-codefile additional / external source, header, and include dir property extraction + # + # Source + GET_SOURCE_FILE_PROPERTY(${name}_test_additional_SOURCE_FILES ${source} LL_TEST_ADDITIONAL_SOURCE_FILES) + IF(${name}_test_additional_SOURCE_FILES MATCHES NOTFOUND) + SET(${name}_test_additional_SOURCE_FILES "") + ENDIF(${name}_test_additional_SOURCE_FILES MATCHES NOTFOUND) + SET(${name}_test_SOURCE_FILES ${source} tests/${name}_test.${extension} ${alltest_SOURCE_FILES} ${${name}_test_additional_SOURCE_FILES} ) + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_SOURCE_FILES ${${name}_test_SOURCE_FILES}") + ENDIF(LL_TEST_VERBOSE) + # Headers + GET_SOURCE_FILE_PROPERTY(${name}_test_additional_HEADER_FILES ${source} LL_TEST_ADDITIONAL_HEADER_FILES) + IF(${name}_test_additional_HEADER_FILES MATCHES NOTFOUND) + SET(${name}_test_additional_HEADER_FILES "") + ENDIF(${name}_test_additional_HEADER_FILES MATCHES NOTFOUND) + SET(${name}_test_HEADER_FILES ${name}.h ${${name}_test_additional_HEADER_FILES}) + set_source_files_properties(${${name}_test_HEADER_FILES} PROPERTIES HEADER_FILE_ONLY TRUE) + LIST(APPEND ${name}_test_SOURCE_FILES ${${name}_test_HEADER_FILES}) + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_HEADER_FILES ${${name}_test_HEADER_FILES}") + ENDIF(LL_TEST_VERBOSE) + # Include dirs + GET_SOURCE_FILE_PROPERTY(${name}_test_additional_INCLUDE_DIRS ${source} LL_TEST_ADDITIONAL_INCLUDE_DIRS) + IF(${name}_test_additional_INCLUDE_DIRS MATCHES NOTFOUND) + SET(${name}_test_additional_INCLUDE_DIRS "") + ENDIF(${name}_test_additional_INCLUDE_DIRS MATCHES NOTFOUND) + INCLUDE_DIRECTORIES(${alltest_INCLUDE_DIRS} ${name}_test_additional_INCLUDE_DIRS ) + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_INCLUDE_DIRS ${${name}_test_additional_INCLUDE_DIRS}") + ENDIF(LL_TEST_VERBOSE) + + # Setup target + ADD_EXECUTABLE(PROJECT_${project}_TEST_${name} ${${name}_test_SOURCE_FILES}) + + # + # Per-codefile additional / external project dep and lib dep property extraction + # + # WARNING: it's REALLY IMPORTANT to not mix these. I guarantee it will not work in the future. + poppy 2009-04-19 + # Projects + GET_SOURCE_FILE_PROPERTY(${name}_test_additional_PROJECTS ${source} LL_TEST_ADDITIONAL_PROJECTS) + IF(${name}_test_additional_PROJECTS MATCHES NOTFOUND) + SET(${name}_test_additional_PROJECTS "") + ENDIF(${name}_test_additional_PROJECTS MATCHES NOTFOUND) + # Libraries + GET_SOURCE_FILE_PROPERTY(${name}_test_additional_LIBRARIES ${source} LL_TEST_ADDITIONAL_LIBRARIES) + IF(${name}_test_additional_LIBRARIES MATCHES NOTFOUND) + SET(${name}_test_additional_LIBRARIES "") + ENDIF(${name}_test_additional_LIBRARIES MATCHES NOTFOUND) + IF(LL_TEST_VERBOSE) + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_PROJECTS ${${name}_test_additional_PROJECTS}") + MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_LIBRARIES ${${name}_test_additional_LIBRARIES}") + ENDIF(LL_TEST_VERBOSE) + # Add to project + TARGET_LINK_LIBRARIES(PROJECT_${project}_TEST_${name} ${alltest_LIBRARIES} ${alltest_DEP_TARGETS} ${${name}_test_additional_PROJECTS} ${${name}_test_additional_LIBRARIES} ) + + # + # Setup test targets + # + GET_TARGET_PROPERTY(TEST_EXE PROJECT_${project}_TEST_${name} LOCATION) + SET(TEST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PROJECT_${project}_TEST_${name}_ok.txt) + SET(TEST_CMD ${TEST_EXE} --touch=${TEST_OUTPUT} --sourcedir=${CMAKE_CURRENT_SOURCE_DIR}) + # daveh - what configuration does this use? Debug? it's cmake-time, not build time. + poppy 2009-04-19 + IF(LL_TEST_VERBOSE) + MESSAGE(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_cmd = ${TEST_CMD}") + ENDIF(LL_TEST_VERBOSE) SET(TEST_SCRIPT_CMD ${CMAKE_COMMAND} -DLD_LIBRARY_PATH=${ARCH_PREBUILT_DIRS}:/usr/lib -DTEST_CMD:STRING="${TEST_CMD}" -P ${CMAKE_SOURCE_DIR}/cmake/RunBuildTest.cmake ) - - #MESSAGE(STATUS "ADD_BUILD_TEST_INTERNAL ${name} test_script = ${TEST_SCRIPT_CMD}") + IF(LL_TEST_VERBOSE) + MESSAGE(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_script = ${TEST_SCRIPT_CMD}") + ENDIF(LL_TEST_VERBOSE) + # Add test ADD_CUSTOM_COMMAND( OUTPUT ${TEST_OUTPUT} COMMAND ${TEST_SCRIPT_CMD} - DEPENDS ${name}_test + DEPENDS PROJECT_${project}_TEST_${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) + # Why not add custom target and add POST_BUILD command? + # Slightly less uncertain behavior + # (OUTPUT commands run non-deterministically AFAIK) + poppy 2009-04-19 + # > I did not use a post build step as I could not make it notify of a + # > failure after the first time you build and fail a test. - daveh 2009-04-20 + LIST(APPEND ${project}_TEST_OUTPUT ${TEST_OUTPUT}) + ENDFOREACH (source) + + # Add the test runner target per-project + # (replaces old _test_ok targets all over the place) + ADD_CUSTOM_TARGET(${project}_tests ALL DEPENDS ${${project}_TEST_OUTPUT}) + ADD_DEPENDENCIES(${project} ${project}_tests) +ENDMACRO(LL_ADD_PROJECT_UNIT_TESTS) - ADD_CUSTOM_TARGET(${name}_test_ok ALL DEPENDS ${TEST_OUTPUT}) - IF (${parent}) - ADD_DEPENDENCIES(${parent} ${name}_test_ok) - ENDIF (${parent}) - -ENDMACRO(ADD_BUILD_TEST_INTERNAL name parent libraries source_files) - - -MACRO(ADD_COMM_BUILD_TEST name parent wrapper) -## MESSAGE(STATUS "ADD_COMM_BUILD_TEST ${name} wrapper = ${wrapper}") - # optional extra parameter: list of additional source files - SET(more_source_files "${ARGN}") -## MESSAGE(STATUS "ADD_COMM_BUILD_TEST ${name} more_source_files = ${more_source_files}") - - SET(libraries - ${LLMESSAGE_LIBRARIES} - ${LLMATH_LIBRARIES} - ${LLVFS_LIBRARIES} - ${LLCOMMON_LIBRARIES} - ${APRUTIL_LIBRARIES} - ${APR_LIBRARIES} - ${PTHREAD_LIBRARY} - ${WINDOWS_LIBRARIES} - ) - SET(source_files - ${name}.cpp - tests/${name}_test.cpp - ${CMAKE_SOURCE_DIR}/test/test.cpp - ${CMAKE_SOURCE_DIR}/test/lltut.cpp - ${more_source_files} - ) - - ADD_BUILD_TEST_INTERNAL("${name}" "${parent}" "${libraries}" "${source_files}" "${wrapper}") -ENDMACRO(ADD_COMM_BUILD_TEST name parent wrapper) - -MACRO(ADD_VIEWER_COMM_BUILD_TEST name parent wrapper) - # This is just like the generic ADD_COMM_BUILD_TEST, but we implicitly - # add the necessary precompiled header .cpp file (anyone else find that - # oxymoronic?) because the MSVC build errors will NOT point you there. -## MESSAGE(STATUS "ADD_VIEWER_COMM_BUILD_TEST ${name} wrapper = ${wrapper}") - ADD_COMM_BUILD_TEST("${name}" "${parent}" "${wrapper}" llviewerprecompiledheaders.cpp) -ENDMACRO(ADD_VIEWER_COMM_BUILD_TEST name parent wrapper) diff --git a/indra/develop.py b/indra/develop.py index b40e81bb07..1d7ac42c9c 100755 --- a/indra/develop.py +++ b/indra/develop.py @@ -451,7 +451,9 @@ class DarwinSetup(UnixSetup): targets = ' '.join(['-target ' + repr(t) for t in targets]) else: targets = '' - cmd = ('xcodebuild -configuration %s %s %s' % + # cmd = ('xcodebuild -parallelizeTargets ' # parallelizeTargets is suspected of non-deterministic build failures. + poppy 2009-06-05 + cmd = ('xcodebuild ' + '-configuration %s %s %s' % (self.build_type, ' '.join(opts), targets)) for d in self.build_dirs(): try: diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 51bd4354df..beac8df636 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -3,7 +3,6 @@ project(llcommon) include(00-Common) -include(LLAddBuildTest) include(LLCommon) include_directories( @@ -202,4 +201,10 @@ target_link_libraries( ${ZLIB_LIBRARIES} ) -ADD_BUILD_TEST(lllazy llcommon) +include(LLAddBuildTest) +SET(llcommon_TEST_SOURCE_FILES + # WARNING: Please don't write tests against LLCommon or LLMath until this issue is resolved: https://jira.lindenlab.com/jira/browse/DEV-29456 + # lllazy.cpp + ) +LL_ADD_PROJECT_UNIT_TESTS(llcommon "${llcommon_TEST_SOURCE_FILES}") + diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index 6a329fabb6..075d3b3af0 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -79,3 +79,12 @@ set_source_files_properties(${llmath_HEADER_FILES} list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES}) add_library (llmath ${llmath_SOURCE_FILES}) + + +include(LLAddBuildTest) +SET(llmath_TEST_SOURCE_FILES + # WARNING: Please don't write tests against LLCommon or LLMath until this issue is resolved: https://jira.lindenlab.com/jira/browse/DEV-29456 + # llvolume.cpp + ) +LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}") + diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index c0f7a4d335..88f83ba78e 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -217,9 +217,14 @@ IF (NOT LINUX AND VIEWER) # When building the viewer the tests links against the shared objects. # These can not be found when we try to run the tests, so we had to disable them, for the viewer build. # TODO: Can someone with viewer knowledge figure out how to make these find the correct so. - #ADD_BUILD_TEST(llhttpclientadapter llmessage) - ADD_BUILD_TEST(lltrustedmessageservice llmessage) - ADD_BUILD_TEST(lltemplatemessagedispatcher llmessage) + SET(llmessage_TEST_SOURCE_FILES + # llhttpclientadapter.cpp + lltrustedmessageservice.cpp + lltemplatemessagedispatcher.cpp + ) + LL_ADD_PROJECT_UNIT_TESTS(llmessage "${llmessage_TEST_SOURCE_FILES}") + + # Commented out - see rationale at bottom of newview's build file + poppy 2009-06-05 # Don't make llmessage depend on llsdmessage_test because ADD_COMM_BUILD_TEST depends on llmessage! - ADD_COMM_BUILD_TEST(llsdmessage "" "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py") + # ADD_COMM_BUILD_TEST(llsdmessage "" "${CMAKE_CURRENT_SOURCE_DIR}/tests/test_llsdmessage_peer.py") ENDIF (NOT LINUX AND VIEWER) diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 57f1716db5..0c8486bd4f 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -11,7 +11,6 @@ include(ELFIO) include(FMOD) include(OPENAL) include(FindOpenGL) -include(LLAddBuildTest) include(LLAudio) include(LLCharacter) include(LLCommon) @@ -1393,6 +1392,19 @@ if (INSTALL) include(${CMAKE_CURRENT_SOURCE_DIR}/ViewerInstall.cmake) endif (INSTALL) -ADD_VIEWER_BUILD_TEST(llagentaccess viewer) -ADD_VIEWER_COMM_BUILD_TEST(llcapabilitylistener viewer - ${CMAKE_CURRENT_SOURCE_DIR}/../llmessage/tests/test_llsdmessage_peer.py) +include(LLAddBuildTest) +SET(viewer_TEST_SOURCE_FILES + llagentaccess.cpp + # Not *actually* a unit test, it's an integration test. + # Because it won't work in the new unit test iface, i've commented out + # and notified Nat. Delete this when it's replaced! + # + poppy & brad 2009-06-05 + # llcapabilitylistener.cpp + ) +set_source_files_properties( + ${viewer_TEST_SOURCE_FILES} + PROPERTIES + LL_TEST_ADDITIONAL_SOURCE_FILES llviewerprecompiledheaders.cpp + ) +LL_ADD_PROJECT_UNIT_TESTS(${VIEWER_BINARY_NAME} "${viewer_TEST_SOURCE_FILES}") + |