Change logic of ctest subdirs command to allow for absolute paths. Also added test coverage for passing absolute paths to subdirs.

This commit is contained in:
Zach Mullen 2009-11-10 10:40:24 -05:00
parent 21a59bdc4d
commit c9c0ee4056
8 changed files with 27 additions and 7 deletions

View File

@ -82,17 +82,20 @@ bool cmCTestSubdirCommand
for ( it = args.begin(); it != args.end(); ++ it ) for ( it = args.begin(); it != args.end(); ++ it )
{ {
cmSystemTools::ChangeDirectory(cwd.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str());
std::string fname = cwd; std::string fname;
fname += "/";
fname += *it;
//sanity check on relative path; if not, try absolute path if(cmSystemTools::FileIsFullPath(it->c_str()))
if ( !cmSystemTools::FileIsDirectory(fname.c_str()))
{ {
fname = *it; fname = *it;
} }
else
{
fname = cwd;
fname += "/";
fname += *it;
}
if ( !cmSystemTools::FileExists(fname.c_str()) ) if ( !cmSystemTools::FileIsDirectory(fname.c_str()) )
{ {
// No subdirectory? So what... // No subdirectory? So what...
continue; continue;

View File

@ -1210,6 +1210,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel
-S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V -S "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/test.cmake" -V
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log" --output-log "${CMake_BINARY_DIR}/Tests/CTestTestSubdir/testOutput.log"
) )
#make sure all 3 subdirs were added
SET_TESTS_PROPERTIES(CTestTestSubdir PROPERTIES
PASS_REGULAR_EXPRESSION "0 tests failed out of 3")
CONFIGURE_FILE( CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in" "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in"

View File

@ -9,3 +9,5 @@ GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH)
SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest")
ADD_SUBDIRECTORY(subdir) ADD_SUBDIRECTORY(subdir)
SUBDIRS(subdir2)
SUBDIRS("${CTestTestSubdir_SOURCE_DIR}/subdir3")

View File

@ -1,2 +1,2 @@
ADD_EXECUTABLE (main main.c) ADD_EXECUTABLE (main main.c)
ADD_TEST (TestMain main) ADD_TEST (TestMain1 main)

View File

@ -0,0 +1,2 @@
ADD_EXECUTABLE (main2 main.c)
ADD_TEST (TestMain2 main2)

View File

@ -0,0 +1,4 @@
int main(void)
{
return 0;
}

View File

@ -0,0 +1,2 @@
ADD_EXECUTABLE (main3 main.c)
ADD_TEST (TestMain3 main3)

View File

@ -0,0 +1,4 @@
int main(void)
{
return 0;
}