Merge topic 'dev/add_test-working-directory'
d94f9c6 Only set the property if the property was given b6c302b Default the working dir to the current binary dir 0594287 Add more tests for WorkingDirectory for tests
This commit is contained in:
commit
0159424fda
@ -170,7 +170,10 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
|
||||
cmTest* test = this->Makefile->CreateTest(name.c_str());
|
||||
test->SetOldStyle(false);
|
||||
test->SetCommand(command);
|
||||
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
|
||||
if(!working_directory.empty())
|
||||
{
|
||||
test->SetProperty("WORKING_DIRECTORY", working_directory.c_str());
|
||||
}
|
||||
this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations));
|
||||
|
||||
return true;
|
||||
|
@ -7,6 +7,8 @@ enable_testing()
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
|
||||
|
||||
add_test(NAME WorkingDirectory0 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}")
|
||||
|
||||
add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}")
|
||||
set_tests_properties(WorkingDirectory1 PROPERTIES
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||
@ -19,7 +21,7 @@ set_tests_properties(WorkingDirectory2 PROPERTIES
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.."
|
||||
)
|
||||
|
||||
get_filename_component(_default_cwd "${EXECUTABLE_OUTPUT_PATH}" PATH)
|
||||
set(_default_cwd "${CMAKE_BINARY_DIR}")
|
||||
|
||||
# FIXME: How to deal with /debug, /release, etc. with VS or XCode?
|
||||
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
||||
@ -36,3 +38,5 @@ add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND
|
||||
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
||||
add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
||||
endif()
|
||||
|
||||
add_subdirectory(subdir)
|
||||
|
31
Tests/TestsWorkingDirectory/subdir/CMakeLists.txt
Normal file
31
Tests/TestsWorkingDirectory/subdir/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
add_test(NAME WorkingDirectory-Subdir0 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_test(NAME WorkingDirectory-Subdir1 COMMAND WorkingDirectory "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
set_tests_properties(WorkingDirectory-Subdir1 PROPERTIES
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_test(NAME WorkingDirectory-Subdir2 COMMAND WorkingDirectory "${_parent_dir}")
|
||||
set_tests_properties(WorkingDirectory-Subdir2 PROPERTIES
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.."
|
||||
)
|
||||
|
||||
set(_default_cwd "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# FIXME: How to deal with /debug, /release, etc. with VS or XCode?
|
||||
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
||||
add_test(WorkingDirectory-Subdir3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd})
|
||||
endif()
|
||||
|
||||
add_test(NAME WorkingDirectory-Subdir4 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND WorkingDirectory ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_test(NAME WorkingDirectory-Subdir5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir})
|
||||
|
||||
# FIXME: How to deal with /debug, /release, etc. with VS or XCode?
|
||||
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
||||
add_test(WorkingDirectory-Subdir6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user