Browse Source

Tests: Add --build-and-test test case

Checks that giving an invalid build directory to
ctest --build-and-test will fail.
Craig Scott 7 years ago
parent
commit
e654622aee

+ 6 - 0
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}"
+)

+ 3 - 0
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()

+ 1 - 0
Tests/RunCMake/WorkingDirectory/buildAndTestNoBuildDir-result.txt

@@ -0,0 +1 @@
+^[^0][0-9]*$

+ 7 - 0
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
+)