From c9c0ee4056aa651a63ee6c34abb06e60e987dbe3 Mon Sep 17 00:00:00 2001 From: Zach Mullen Date: Tue, 10 Nov 2009 10:40:24 -0500 Subject: Change logic of ctest subdirs command to allow for absolute paths. Also added test coverage for passing absolute paths to subdirs. --- Source/CTest/cmCTestTestHandler.cxx | 15 +++++++++------ Tests/CMakeLists.txt | 3 +++ Tests/CTestTestSubdir/CMakeLists.txt | 2 ++ Tests/CTestTestSubdir/subdir/CMakeLists.txt | 2 +- Tests/CTestTestSubdir/subdir2/CMakeLists.txt | 2 ++ Tests/CTestTestSubdir/subdir2/main.c | 4 ++++ Tests/CTestTestSubdir/subdir3/CMakeLists.txt | 2 ++ Tests/CTestTestSubdir/subdir3/main.c | 4 ++++ 8 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 Tests/CTestTestSubdir/subdir2/CMakeLists.txt create mode 100644 Tests/CTestTestSubdir/subdir2/main.c create mode 100644 Tests/CTestTestSubdir/subdir3/CMakeLists.txt create mode 100644 Tests/CTestTestSubdir/subdir3/main.c diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d314052..f6dede8 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -82,17 +82,20 @@ bool cmCTestSubdirCommand for ( it = args.begin(); it != args.end(); ++ it ) { cmSystemTools::ChangeDirectory(cwd.c_str()); - std::string fname = cwd; - fname += "/"; - fname += *it; + std::string fname; - //sanity check on relative path; if not, try absolute path - if ( !cmSystemTools::FileIsDirectory(fname.c_str())) + if(cmSystemTools::FileIsFullPath(it->c_str())) { fname = *it; } + else + { + fname = cwd; + fname += "/"; + fname += *it; + } - if ( !cmSystemTools::FileExists(fname.c_str()) ) + if ( !cmSystemTools::FileIsDirectory(fname.c_str()) ) { // No subdirectory? So what... continue; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 7552e78..400cfdd 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -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 --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( "${CMake_SOURCE_DIR}/Tests/CTestTestTimeout/test.cmake.in" diff --git a/Tests/CTestTestSubdir/CMakeLists.txt b/Tests/CTestTestSubdir/CMakeLists.txt index f5a1fe2..5daa543 100644 --- a/Tests/CTestTestSubdir/CMakeLists.txt +++ b/Tests/CTestTestSubdir/CMakeLists.txt @@ -9,3 +9,5 @@ GET_FILENAME_COMPONENT(CTEST_COMMAND "${CMAKE_COMMAND}" PATH) SET(CTEST_COMMAND "${CTEST_COMMAND}/ctest") ADD_SUBDIRECTORY(subdir) +SUBDIRS(subdir2) +SUBDIRS("${CTestTestSubdir_SOURCE_DIR}/subdir3") diff --git a/Tests/CTestTestSubdir/subdir/CMakeLists.txt b/Tests/CTestTestSubdir/subdir/CMakeLists.txt index a92e13b..b40d316 100644 --- a/Tests/CTestTestSubdir/subdir/CMakeLists.txt +++ b/Tests/CTestTestSubdir/subdir/CMakeLists.txt @@ -1,2 +1,2 @@ ADD_EXECUTABLE (main main.c) -ADD_TEST (TestMain main) +ADD_TEST (TestMain1 main) diff --git a/Tests/CTestTestSubdir/subdir2/CMakeLists.txt b/Tests/CTestTestSubdir/subdir2/CMakeLists.txt new file mode 100644 index 0000000..23f8e07 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir2/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (main2 main.c) +ADD_TEST (TestMain2 main2) diff --git a/Tests/CTestTestSubdir/subdir2/main.c b/Tests/CTestTestSubdir/subdir2/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/CTestTestSubdir/subdir2/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/CTestTestSubdir/subdir3/CMakeLists.txt b/Tests/CTestTestSubdir/subdir3/CMakeLists.txt new file mode 100644 index 0000000..9a44b12 --- /dev/null +++ b/Tests/CTestTestSubdir/subdir3/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_EXECUTABLE (main3 main.c) +ADD_TEST (TestMain3 main3) diff --git a/Tests/CTestTestSubdir/subdir3/main.c b/Tests/CTestTestSubdir/subdir3/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/CTestTestSubdir/subdir3/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} -- cgit v0.12