summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/RunCMake/CommandLine')
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake8
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt2
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/RunCMakeTest.cmake125
-rw-r--r--Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake3
-rw-r--r--Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt7
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt1
-rw-r--r--Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt1
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1-check.cmake11
-rwxr-xr-xTests/RunCMake/CommandLine/trace-json-v1-check.py76
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake11
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake1
-rw-r--r--Tests/RunCMake/CommandLine/trace-json-v1.cmake5
55 files changed, 318 insertions, 0 deletions
diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt
new file mode 100644
index 0000000..62b963a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_bad_argument-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Unknown -E rm argument: -rd$
diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake
new file mode 100644
index 0000000..b1a29a2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/dir/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_directory_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt
new file mode 100644
index 0000000..1ac7dba
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Missing file/directory to remove$
diff --git a/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake
new file mode 100644
index 0000000..6cd4edd
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_empty_file_specified.cmake
@@ -0,0 +1,8 @@
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E rm ""
+ RESULT_VARIABLE actual_result
+ )
+
+if(NOT "${actual_result}" EQUAL "1")
+ message(SEND_ERROR "cmake -E rm \"\" should have returned 1, got ${actual_result}")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_force_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake
new file mode 100644
index 0000000..a0a9b20
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_link_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt
new file mode 100644
index 0000000..05df88a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_non_force_non_existing-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake
new file mode 100644
index 0000000..e28b160
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt
new file mode 100644
index 0000000..05df88a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_file_recursive_non_existing-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: File to remove does not exist and force is not set: .*/rm_tests/not_existing.txt
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake
new file mode 100644
index 0000000..1a976cb
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out})
+ set(RunCMake_TEST_FAILED "${out} not removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_directory_with_files-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_force_recursive_non_existing_file-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt
new file mode 100644
index 0000000..1ac7dba
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_no_file_specified-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Missing file/directory to remove$
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake
new file mode 100644
index 0000000..609271e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/d1 OR NOT EXISTS ${out}/d2)
+ set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 is removed but should not")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt
new file mode 100644
index 0000000..33ea2e3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_non_recursive_directory-two-directories-stderr.txt
@@ -0,0 +1,2 @@
+^Error removing directory ".*/rm_tests/d1" without recursive option\.
+Error removing directory ".*/rm_tests/d2" without recursive option\.$
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake
new file mode 100644
index 0000000..5282da7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS ${out}/d1 OR EXISTS ${out}/d2)
+ set(RunCMake_TEST_FAILED "${out}/d1 or ${out}/d2 should be removed")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory-two-directories-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake
new file mode 100644
index 0000000..b1a29a2
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/dir/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/dir/existing.txt should exist (we only removed the link to dir folder)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_directory_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake
new file mode 100644
index 0000000..a0a9b20
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS ${out}/existing.txt)
+ set(RunCMake_TEST_FAILED "${out}/existing.txt should exist (we only removed the link)")
+endif()
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_rm_recursive_file_link_non_existing-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index b608d33..8930721 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -254,6 +254,24 @@ function(run_EnvironmentGenerator)
endfunction()
run_EnvironmentGenerator()
+function(run_EnvironmentExportCompileCommands)
+ set(RunCMake_TEST_SOURCE_DIR ${RunCMake_SOURCE_DIR}/env-export-compile-commands)
+
+ run_cmake(env-export-compile-commands-unset)
+
+ set(ENV{CMAKE_EXPORT_COMPILE_COMMANDS} ON)
+ run_cmake(env-export-compile-commands-set)
+
+ set(RunCMake_TEST_OPTIONS -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF)
+ run_cmake(env-export-compile-commands-override)
+
+ unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS})
+endfunction(run_EnvironmentExportCompileCommands)
+
+if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ninja")
+ run_EnvironmentExportCompileCommands()
+endif()
+
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
@@ -370,6 +388,76 @@ endif()
unset(out)
unset(outfile)
+set(out ${RunCMake_BINARY_DIR}/rm_tests)
+file(REMOVE_RECURSE "${out}")
+file(MAKE_DIRECTORY ${out})
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_force_existing
+ ${CMAKE_COMMAND} -E rm -f ${out}/existing.txt)
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_non_force_existing
+ ${CMAKE_COMMAND} -E rm ${out}/existing.txt)
+run_cmake_command(E_rm_file_force_non_existing
+ ${CMAKE_COMMAND} -E rm -f ${out}/not_existing.txt)
+run_cmake_command(E_rm_file_non_force_non_existing
+ ${CMAKE_COMMAND} -E rm ${out}/not_existing.txt)
+
+file(TOUCH ${out}/existing.txt)
+run_cmake_command(E_rm_file_recursive_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/existing.txt)
+run_cmake_command(E_rm_file_recursive_non_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/not_existing.txt)
+
+file(MAKE_DIRECTORY ${out}/d1 ${out}/d2)
+run_cmake_command(E_rm_non_recursive_directory-two-directories
+ ${CMAKE_COMMAND} -E rm ${out}/d1 ${out}/d2)
+
+run_cmake_command(E_rm_recursive_directory-two-directories
+ ${CMAKE_COMMAND} -E rm -R ${out}/d1 ${out}/d2)
+
+run_cmake_command(E_rm_no_file_specified
+ ${CMAKE_COMMAND} -E rm -rf)
+
+run_cmake_command(E_rm_empty_file_specified
+ ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_rm_empty_file_specified.cmake)
+
+run_cmake_command(E_rm_bad_argument
+ ${CMAKE_COMMAND} -E rm -rd ${out}/d1 ${out}/d2)
+
+file(MAKE_DIRECTORY ${out}/d1 ${out}/d2)
+file(WRITE ${out}/test.txt "")
+run_cmake_command(E_rm_force_recursive_directory_with_files
+ ${CMAKE_COMMAND} -E rm -rf ${out}/)
+
+run_cmake_command(E_rm_force_recursive_non_existing_file
+ ${CMAKE_COMMAND} -E rm -Rf ${out}/test.txt)
+
+if(NOT WIN32 AND NOT CYGWIN)
+ file(MAKE_DIRECTORY ${out})
+ file(TOUCH ${out}/existing.txt)
+ file(MAKE_DIRECTORY ${out}/dir)
+ file(TOUCH ${out}/dir/existing.txt) # add a file in the folder
+ file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
+ file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC)
+ file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC)
+ run_cmake_command(E_rm_file_link_existing
+ ${CMAKE_COMMAND} -E rm ${out}/existing_file_link.txt)
+ run_cmake_command(E_rm_directory_link_existing
+ ${CMAKE_COMMAND} -E rm ${out}/link_dir)
+ run_cmake_command(E_rm_file_link_non_existing
+ ${CMAKE_COMMAND} -E rm ${out}/non_existing_file_link.txt)
+
+ file(CREATE_LINK ${out}/dir ${out}/link_dir SYMBOLIC)
+ file(CREATE_LINK ${out}/existing.txt ${out}/existing_file_link.txt SYMBOLIC)
+ file(CREATE_LINK ${out}/non_existing.txt ${out}/non_existing_file_link.txt SYMBOLIC)
+ run_cmake_command(E_rm_recursive_file_link_existing
+ ${CMAKE_COMMAND} -E rm -R ${out}/existing_file_link.txt)
+ run_cmake_command(E_rm_recursive_directory_link_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/link_dir)
+ run_cmake_command(E_rm_recursive_file_link_non_existing
+ ${CMAKE_COMMAND} -E rm -r ${out}/non_existing_file_link.txt)
+endif()
+unset(out)
run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env)
run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
@@ -519,6 +607,14 @@ set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt)
run_cmake(trace-redirect-nofile)
unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_TEST_OPTIONS --trace --trace-format=json-v1 --trace-redirect=${RunCMake_BINARY_DIR}/json-v1.trace)
+run_cmake(trace-json-v1)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --trace-expand --trace-format=json-v1 --trace-redirect=${RunCMake_BINARY_DIR}/json-v1-expand.trace)
+run_cmake(trace-json-v1-expand)
+unset(RunCMake_TEST_OPTIONS)
+
set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized)
run_cmake(warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
@@ -571,3 +667,32 @@ if(CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
run_cmake_command(closed_stderr sh -c "\"${CMAKE_COMMAND}\" --version 2>&-")
run_cmake_command(closed_stdall sh -c "\"${CMAKE_COMMAND}\" --version <&- >&- 2>&-")
endif()
+
+function(run_llvm_rc)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/llvm_rc-build")
+ set(RunCMake_TEST_NO_CLEAN 1)
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ run_cmake_command(llvm_rc_no_args ${CMAKE_COMMAND} -E cmake_llvm_rc)
+ run_cmake_command(llvm_rc_no_-- ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test")
+ run_cmake_command(llvm_rc_empty_preprocessor ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp -- ${CMAKE_COMMAND} -E echo "This is a test")
+ run_cmake_command(llvm_rc_failing_first_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -P FailedProgram.cmake -- ${CMAKE_COMMAND} -E echo "This is a test")
+ run_cmake_command(llvm_rc_failing_second_command ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -P FailedProgram.cmake )
+ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/test.tmp)
+ message(SEND_ERROR "${test} - FAILED:\n"
+ "test.tmp was not deleted")
+ endif()
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir")
+ run_cmake_command(llvm_rc_full_run ${CMAKE_COMMAND} -E cmake_llvm_rc ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/source_file test.tmp ${CMAKE_COMMAND} -E echo "This is a test" -- ${CMAKE_COMMAND} -E copy test.tmp SOURCE_DIR/llvmrc.result )
+ if(EXISTS ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/test.tmp)
+ message(SEND_ERROR "${test} - FAILED:\n"
+ "test.tmp was not deleted")
+ endif()
+ file(READ ${RunCMake_TEST_BINARY_DIR}/ExpandSourceDir/llvmrc.result LLVMRC_RESULT)
+ if(NOT "${LLVMRC_RESULT}" STREQUAL "This is a test\n")
+ message(SEND_ERROR "${test} - FAILED:\n"
+ "llvmrc.result was not created")
+ endif()
+ unset(LLVMRC_RESULT)
+endfunction()
+run_llvm_rc()
diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake
new file mode 100644
index 0000000..032a1ae
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-override-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json")
+ set(RunCMake_TEST_FAILED "compile_commands.json generated with CMAKE_EXPORT_COMPILE_COMMANDS overridden")
+endif()
diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake
new file mode 100644
index 0000000..a749a55
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-set-check.cmake
@@ -0,0 +1,3 @@
+if(NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json")
+ set(RunCMake_TEST_FAILED "compile_commands.json not generated with CMAKE_EXPORT_COMPILE_COMMANDS set")
+endif()
diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake b/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake
new file mode 100644
index 0000000..c5878f0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/env-export-compile-commands-unset-check.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${RunCMake_TEST_BINARY_DIR}/compile_commands.json")
+ set(RunCMake_TEST_FAILED "compile_commands.json generated with CMAKE_EXPORT_COMPILE_COMMANDS unset")
+endif()
diff --git a/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt b/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt
new file mode 100644
index 0000000..aa6fbfd
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/env-export-compile-commands/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.14)
+project(env-export-compile-commands C)
+
+# Add target with a source file to make sure compile_commands.json gets
+# generated.
+file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/main.c)
+add_executable(env-export-compile-commands ${CMAKE_CURRENT_BINARY_DIR}/main.c)
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt
new file mode 100644
index 0000000..cb69366
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_empty_preprocessor-stderr.txt
@@ -0,0 +1 @@
+Empty preprocessing command
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt
new file mode 100644
index 0000000..765b708
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_first_command-stderr.txt
@@ -0,0 +1 @@
+CMake Error
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt
new file mode 100644
index 0000000..765b708
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_failing_second_command-stderr.txt
@@ -0,0 +1 @@
+CMake Error
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_no_---result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt
new file mode 100644
index 0000000..9c140b7
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_no_---stderr.txt
@@ -0,0 +1 @@
+Empty resource compilation command
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_no_args-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt b/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt
new file mode 100644
index 0000000..d66b547
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/llvm_rc_no_args-stderr.txt
@@ -0,0 +1 @@
+Invalid cmake_llvm_rc arguments
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake
new file mode 100644
index 0000000..66af039
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.cmake
@@ -0,0 +1,11 @@
+if(PYTHON_EXECUTABLE)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" "${RunCMake_BINARY_DIR}/json-v1.trace"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output
+ )
+ if(NOT result EQUAL 0)
+ set(RunCMake_TEST_FAILED "JSON trace validation failed:\n${output}")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
new file mode 100755
index 0000000..e617b76
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+if sys.version_info[0] >= 3:
+ unicode = str
+
+trace_file = None
+expand = False
+
+for i in sys.argv[1:]:
+ if trace_file is None and not i.startswith('-'):
+ trace_file = i
+ continue
+
+ if i in ['-e', '--expand']:
+ expand = True
+
+assert trace_file is not None
+assert os.path.exists(trace_file)
+
+if expand:
+ msg_args = ['STATUS', 'fff', 'fff;sss; SPACES !!! ', ' 42 space in string!', ' SPACES !!! ']
+else:
+ msg_args = ['STATUS', 'fff', '${ASDF}', ' ${FOO} ${BAR}', ' SPACES !!! ']
+
+required_traces = [
+ {
+ 'args': ['STATUS', 'JSON-V1 str', 'spaces'],
+ 'cmd': 'message',
+ },
+ {
+ 'args': ['ASDF', 'fff', 'sss', ' SPACES !!! '],
+ 'cmd': 'set',
+ },
+ {
+ 'args': ['FOO', '42'],
+ 'cmd': 'set',
+ },
+ {
+ 'args': ['BAR', ' space in string!'],
+ 'cmd': 'set',
+ },
+ {
+ 'args': msg_args,
+ 'cmd': 'message',
+ 'frame': 3 if expand else 2
+ },
+]
+
+with open(trace_file, 'r') as fp:
+ # Check for version (must be the first document)
+ vers = json.loads(fp.readline())
+ assert sorted(vers.keys()) == ['version']
+ assert sorted(vers['version'].keys()) == ['major', 'minor']
+ assert vers['version']['major'] == 1
+ assert vers['version']['minor'] == 0
+
+ for i in fp.readlines():
+ line = json.loads(i)
+ assert sorted(line.keys()) == ['args', 'cmd', 'file', 'frame', 'line', 'time']
+ assert isinstance(line['args'], list)
+ assert isinstance(line['cmd'], unicode)
+ assert isinstance(line['file'], unicode)
+ assert isinstance(line['frame'], int)
+ assert isinstance(line['line'], int)
+ assert isinstance(line['time'], float)
+
+ for j in required_traces:
+ # Compare the subset of required keys with line
+ if {k: line[k] for k in j} == j:
+ required_traces.remove(j)
+
+assert not required_traces
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake
new file mode 100644
index 0000000..7916d2e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-expand-check.cmake
@@ -0,0 +1,11 @@
+if(PYTHON_EXECUTABLE)
+ execute_process(
+ COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/trace-json-v1-check.py" --expand "${RunCMake_BINARY_DIR}/json-v1-expand.trace"
+ RESULT_VARIABLE result
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output
+ )
+ if(NOT result EQUAL 0)
+ set(RunCMake_TEST_FAILED "JSON trace validation failed:\n${output}")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake b/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake
new file mode 100644
index 0000000..5c190e6
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-expand.cmake
@@ -0,0 +1 @@
+include(trace-json-v1.cmake)
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
new file mode 100644
index 0000000..ed0a0f9
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
@@ -0,0 +1,5 @@
+message(STATUS "JSON-V1 str" "spaces")
+set(ASDF fff sss " SPACES !!! ")
+set(FOO 42)
+set(BAR " space in string!")
+message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ")