summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-21 19:09:23 (GMT)
committerBrad King <brad.king@kitware.com>2022-03-22 13:27:47 (GMT)
commit9f1471739d83c9e61b6700a0c369b7f7bbb19071 (patch)
tree2fb485885eb07f35342bc17485d27946bc819f92 /Tests/RunCMake/CommandLine
parent7e642a6fa0884cf683a1a50dd5cab93acd1e3950 (diff)
downloadCMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.zip
CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.gz
CMake-9f1471739d83c9e61b6700a0c369b7f7bbb19071.tar.bz2
cmake: Add --fresh option to clear the cache and start from scratch
Simplify the workflow to re-run CMake from scratch as if a build tree were never before processed, regardless of whether it has been. Fixes: #23119
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rw-r--r--Tests/RunCMake/CommandLine/Fresh-stdout.txt4
-rw-r--r--Tests/RunCMake/CommandLine/Fresh.cmake18
-rw-r--r--Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt5
-rw-r--r--Tests/RunCMake/CommandLine/P_arbitrary_args.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/P_fresh-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/P_fresh-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/P_fresh.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake19
8 files changed, 47 insertions, 3 deletions
diff --git a/Tests/RunCMake/CommandLine/Fresh-stdout.txt b/Tests/RunCMake/CommandLine/Fresh-stdout.txt
new file mode 100644
index 0000000..b5cece9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Fresh-stdout.txt
@@ -0,0 +1,4 @@
+-- CMAKE_SOURCE_DIR='[^']*/Tests/RunCMake/CommandLine'
+-- CMAKE_BINARY_DIR='[^']*/Tests/RunCMake/CommandLine/Fresh-build'
+-- OLD CACHED_VAR_1=''
+-- NEW CACHED_VAR_1='CACHED-VALUE-1'
diff --git a/Tests/RunCMake/CommandLine/Fresh.cmake b/Tests/RunCMake/CommandLine/Fresh.cmake
new file mode 100644
index 0000000..9b1695c
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/Fresh.cmake
@@ -0,0 +1,18 @@
+message(STATUS "CMAKE_SOURCE_DIR='${CMAKE_SOURCE_DIR}'")
+message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'")
+message(STATUS "OLD CACHED_VAR_1='${CACHED_VAR_1}'")
+set(CACHED_VAR_1 "CACHED-VALUE-1" CACHE STRING "")
+message(STATUS "NEW CACHED_VAR_1='${CACHED_VAR_1}'")
+set(kept "${CMAKE_BINARY_DIR}/kept")
+set(removed "${CMAKE_BINARY_DIR}/CMakeFiles/removed")
+if(FIRST)
+ file(WRITE "${kept}" "")
+ file(WRITE "${removed}" "")
+else()
+ if(NOT EXISTS "${kept}")
+ message(FATAL_ERROR "File was not kept:\n ${kept}")
+ endif()
+ if(EXISTS "${removed}")
+ message(FATAL_ERROR "File was not removed:\n ${removed}")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
index c0f96f3..c94c19d 100644
--- a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
@@ -1,8 +1,9 @@
-^-- CMAKE_ARGC='7'
+^-- CMAKE_ARGC='8'
-- CMAKE_ARGV1='-P'
-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake'
-- CMAKE_ARGV3='--'
-- CMAKE_ARGV4='-DFOO'
-- CMAKE_ARGV5='-S'
-- CMAKE_ARGV6='-B'
--- CMAKE_ARGV7=''$
+-- CMAKE_ARGV7='--fresh'
+-- CMAKE_ARGV8=''$
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
index d0a4859..8dca990 100644
--- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
@@ -6,3 +6,4 @@ message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'")
message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'")
message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'")
message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'")
+message(STATUS "CMAKE_ARGV8='${CMAKE_ARGV8}'")
diff --git a/Tests/RunCMake/CommandLine/P_fresh-result.txt b/Tests/RunCMake/CommandLine/P_fresh-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_fresh-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/P_fresh-stderr.txt b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt
new file mode 100644
index 0000000..0c5b035
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_fresh-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: --fresh allowed only when configuring a project$
diff --git a/Tests/RunCMake/CommandLine/P_fresh.cmake b/Tests/RunCMake/CommandLine/P_fresh.cmake
new file mode 100644
index 0000000..dfedce1
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_fresh.cmake
@@ -0,0 +1 @@
+message(FATAL_ERROR "This code should not be reached.")
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 22a59f2..c8234ec 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -52,7 +52,8 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G)
run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator)
run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
-run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B)
+run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh)
+run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh)
run_cmake_command(build-no-dir
${CMAKE_COMMAND} --build)
@@ -212,6 +213,22 @@ message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'")
endfunction()
run_ExplicitDirs()
+function(run_Fresh)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Fresh-build")
+
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-empty")
+ run_cmake_with_options(Fresh --fresh -DFIRST=ON)
+ set(RunCMake_TEST_NO_CLEAN 1)
+
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-reconfig")
+ run_cmake_with_options(Fresh --fresh)
+
+ set(RunCMake_TEST_VARIANT_DESCRIPTION "-src-from-cache")
+ set(RunCMake_TEST_NO_SOURCE_DIR 1)
+ run_cmake_with_options(Fresh --fresh "${RunCMake_TEST_BINARY_DIR}")
+endfunction()
+run_Fresh()
+
function(run_Toolchain)
set(RunCMake_TEST_NO_SOURCE_DIR 1)
set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain)