Skip to content

Commit

Permalink
Merge pull request #508 from Autodesk/sabrih/add_ovveride_working_dir…
Browse files Browse the repository at this point in the history
…ectory

Add override flag for setting WORKING_DIRECTORY
  • Loading branch information
Krystian Ligenza authored May 22, 2020
2 parents 371227e + eb572e0 commit ffd3e13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmake/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
)

Expand All @@ -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
# --------------
Expand Down Expand Up @@ -116,7 +124,7 @@ finally:

add_test(
NAME "${test_name}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
WORKING_DIRECTORY ${working_dir}
COMMAND ${command}
)

Expand Down
1 change: 1 addition & 0 deletions test/lib/ufe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ mayaUsd_copyDirectory(${TARGET_NAME}
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"
Expand Down

0 comments on commit ffd3e13

Please sign in to comment.