From e654622aee22655c418a9c663fad79243ca0c819 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sun, 4 Mar 2018 21:30:35 +1100 Subject: Tests: Add --build-and-test test case Checks that giving an invalid build directory to ctest --build-and-test will fail. --- Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake | 6 ++++++ Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake | 3 +++ Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt | 1 + Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake | 7 +++++++ 4 files changed, 17 insertions(+) create mode 100644 Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake create mode 100644 Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt create mode 100644 Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake diff --git a/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake index a57cacb..a7685ae 100644 --- a/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/WorkingDirectory/RunCMakeTest.cmake @@ -1,3 +1,9 @@ include(RunCTest) run_ctest(dirNotExist) +run_ctest(buildAndTestNoBuildDir + --build-and-test + ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir + ${RunCMake_BINARY_DIR}/buildAndTestNoBuildDir/CMakeLists.txt # Deliberately a file + --build-generator "${RunCMake_GENERATOR}" +) diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake new file mode 100644 index 0000000..fcfe461 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-check.cmake @@ -0,0 +1,3 @@ +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt) + set(RunCMake_TEST_FAILED "Default build dir ${RunCMake_TEST_BINARY_DIR} was used, should not have been") +endif() diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt new file mode 100644 index 0000000..0617a38 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt @@ -0,0 +1 @@ +^[^0][0-9]*$ diff --git a/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake new file mode 100644 index 0000000..ad795c4 --- /dev/null +++ b/Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir.cmake @@ -0,0 +1,7 @@ +# We want a single test that always passes. We should never actually get to +# configure with this file, so we use a successful configure-build-test +# sequence to denote failure of the test case. +include(CTest) +add_test(NAME willPass + COMMAND ${CMAKE_COMMAND} -E touch someFile.txt +) -- cgit v0.12