Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add override flag for setting WORKING_DIRECTORY #508

Merged
merged 1 commit into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()

Comment on lines +78 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look at this again, I realize this can simplified. I will make a commit to address this.
if(NOT PREFIX_WORKING_DIRECTORY)
set(working_dir ${CMAKE_CURRENT_SOURCE_DIR})
endif()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I don't quite understand your fix - I think the set(working_dir ${PREFIX_WORKING_DIRECTORY}) is needed, isn't it? Or are there other changes, too? I guess I'll wait for the actual commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elrond79 Sorry, Yes ignore my comment here. I am not sure what I was thinking when I wrote this comment. It has been a long day......

Everything as is should be fine. Thanks.

# --------------
# 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 @@ -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"
Expand Down