diff --git a/cmake/test.cmake b/cmake/test.cmake index fbbf8afe4c..a9deb37892 100644 --- a/cmake/test.cmake +++ b/cmake/test.cmake @@ -15,6 +15,7 @@ endfunction() # PYTHON_COMMAND - Python code to execute; should call sys.exit # with an appropriate exitcode to indicate success # or failure. +# WORKING_DIRECTORY - Directory from which the test executable will be called. # COMMAND - Command line to execute as a test # NO_STANDALONE_INIT - Only allowable with PYTHON_MODULE or # PYTHON_COMMAND. With those modes, this @@ -49,9 +50,9 @@ function(mayaUsd_add_test test_name) # ----------------- cmake_parse_arguments(PREFIX - "NO_STANDALONE_INIT" # options - "PYTHON_MODULE;PYTHON_COMMAND" # one_value keywords - "COMMAND;ENV" # multi_value keywords + "NO_STANDALONE_INIT" # options + "PYTHON_MODULE;PYTHON_COMMAND;WORKING_DIRECTORY" # one_value keywords + "COMMAND;ENV" # multi_value keywords ${ARGN} ) @@ -74,6 +75,13 @@ function(mayaUsd_add_test test_name) "used with PYTHON_MODULE or PYTHON_COMMAND") endif() + # set the working_dir + if(PREFIX_WORKING_DIRECTORY) + set(working_dir ${PREFIX_WORKING_DIRECTORY}) + else() + set(working_dir ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + # -------------- # 2) Create test # -------------- @@ -116,7 +124,7 @@ finally: add_test( NAME "${test_name}" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${working_dir} COMMAND ${command} ) diff --git a/test/lib/ufe/CMakeLists.txt b/test/lib/ufe/CMakeLists.txt index 53168d6baa..f0599216e5 100644 --- a/test/lib/ufe/CMakeLists.txt +++ b/test/lib/ufe/CMakeLists.txt @@ -56,6 +56,7 @@ mayaUsd_copyFiles(${TARGET_NAME} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} foreach(script ${test_script_files}) mayaUsd_get_unittest_target(target ${script}) mayaUsd_add_test(${target} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} PYTHON_MODULE ${target} ENV "MAYA_PLUG_IN_PATH=${CMAKE_CURRENT_BINARY_DIR}/ufeTestPlugins"