diff options
Diffstat (limited to 'Tests')
24 files changed, 110 insertions, 27 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/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt b/Tests/RunCMake/CommandLine/P_fresh-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-result.txt +++ b/Tests/RunCMake/CommandLine/P_fresh-result.txt 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) diff --git a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake index a64af95..a487f37 100644 --- a/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLineTar/RunCMakeTest.cmake @@ -34,3 +34,9 @@ run_cmake(zip) # Extracting only selected files or directories run_cmake(zip-filtered) + +# Use the --mtime option to set the mtime when creating archive +run_cmake(set-mtime) + +# Use the --touch option to avoid extracting the mtime +run_cmake(touch-mtime) diff --git a/Tests/RunCMake/CommandLineTar/mtime-tests.cmake b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake new file mode 100644 index 0000000..8b4f098 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/mtime-tests.cmake @@ -0,0 +1,9 @@ +set(OUTPUT_NAME "test.tar") + +set(ARCHIVE_MTIME "1970-01-01UTC") +set(ARCHIVE_MTIME_RFC3339 "1970-01-01T00:00:00Z") + +set(COMPRESSION_FLAGS cvf) +set(COMPRESSION_OPTIONS --mtime=${ARCHIVE_MTIME}) + +set(DECOMPRESSION_FLAGS xvf) diff --git a/Tests/RunCMake/CommandLineTar/set-mtime.cmake b/Tests/RunCMake/CommandLineTar/set-mtime.cmake new file mode 100644 index 0000000..333cc88 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/set-mtime.cmake @@ -0,0 +1,11 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(NOT MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "Extracted timestamp ${MTIME} does not match expected ${ARCHIVE_MTIME_RFC3339}") + endif() +endforeach() diff --git a/Tests/RunCMake/CommandLineTar/touch-mtime.cmake b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake new file mode 100644 index 0000000..c9e3524 --- /dev/null +++ b/Tests/RunCMake/CommandLineTar/touch-mtime.cmake @@ -0,0 +1,13 @@ +include(${CMAKE_CURRENT_LIST_DIR}/mtime-tests.cmake) + +set(DECOMPRESSION_OPTIONS --touch) + +include(${CMAKE_CURRENT_LIST_DIR}/roundtrip.cmake) + +foreach(file ${CHECK_FILES}) + file(TIMESTAMP ${FULL_DECOMPRESS_DIR}/${COMPRESS_DIR}/${file} MTIME UTC) + if(MTIME STREQUAL ARCHIVE_MTIME_RFC3339) + message(FATAL_ERROR + "File has unexpected timestamp ${MTIME}") + endif() +endforeach() diff --git a/Tests/RunCMake/define_property/RunCMakeTest.cmake b/Tests/RunCMake/define_property/RunCMakeTest.cmake index 7d7c75b..93eaf1b 100644 --- a/Tests/RunCMake/define_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/define_property/RunCMakeTest.cmake @@ -6,4 +6,4 @@ run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_1) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-invalid_2) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-non_target) run_cmake(define_property-INITIALIZE_FROM_VARIABLE-wrong_suffix) -run_cmake(define_property-INITIALIZE_FROM_VARIABLE-no_prefix) +run_cmake(define_property-INITIALIZE_FROM_VARIABLE-no_underscore) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt index a7903c9..c5ae467 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_1\.cmake:[0-9]+ \(define_property\): - define_property variable name "CMAKE_PROP1" is reserved + define_property variable name "CMAKE_Test_PROP1" is reserved Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake index 873263a..edb8852 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_1.cmake @@ -1,3 +1,3 @@ -define_property(TARGET PROPERTY PROP1 - INITIALIZE_FROM_VARIABLE CMAKE_PROP1 +define_property(TARGET PROPERTY Test_PROP1 + INITIALIZE_FROM_VARIABLE CMAKE_Test_PROP1 ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt index ea6bc86..3dbee34 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2-stderr.txt @@ -1,4 +1,4 @@ ^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-invalid_2\.cmake:[0-9]+ \(define_property\): - define_property variable name "_CMAKE_PROP1" is reserved + define_property variable name "_CMAKE_Test_PROP1" is reserved Call Stack \(most recent call first\): CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake index 95945a3..e1c3ca5 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-invalid_2.cmake @@ -1,3 +1,3 @@ -define_property(TARGET PROPERTY PROP1 - INITIALIZE_FROM_VARIABLE _CMAKE_PROP1 +define_property(TARGET PROPERTY Test_PROP1 + INITIALIZE_FROM_VARIABLE _CMAKE_Test_PROP1 ) diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt deleted file mode 100644 index fc9099c..0000000 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix-stderr.txt +++ /dev/null @@ -1,5 +0,0 @@ -^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-no_prefix\.cmake:[0-9]+ \(define_property\): - define_property Variable name must have a non-empty prefix before property - name "PROP1" -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt new file mode 100644 index 0000000..9bbdd8b --- /dev/null +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at define_property-INITIALIZE_FROM_VARIABLE-no_underscore\.cmake:[0-9]+ \(define_property\): + define_property Property name "PROP1" defined with INITIALIZE_FROM_VARIABLE + does not contain underscore +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore.cmake index cc39b57..cc39b57 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_prefix.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-no_underscore.cmake diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt index 67c186d..ee128ec 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE-subdirectory/CMakeLists.txt @@ -1,11 +1,11 @@ -define_property(TARGET PROPERTY PROP2 +define_property(TARGET PROPERTY Test_PROP2 INITIALIZE_FROM_VARIABLE Test_PROP2 ) -define_property(TARGET PROPERTY PROP3 - INITIALIZE_FROM_VARIABLE Test_PROP3 +define_property(TARGET PROPERTY Test_PROP3 + INITIALIZE_FROM_VARIABLE MyTest_PROP3 ) add_executable(sub_exe ../main.c) -assert_prop_eq(sub_exe PROP1 "Hello") -assert_prop_eq(sub_exe PROP2 "world") -assert_prop_eq(sub_exe PROP3 "!") +assert_prop_eq(sub_exe Test_PROP1 "Hello") +assert_prop_eq(sub_exe Test_PROP2 "world") +assert_prop_eq(sub_exe Test_PROP3 "!") diff --git a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake index d866fc9..5014c74 100644 --- a/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake +++ b/Tests/RunCMake/define_property/define_property-INITIALIZE_FROM_VARIABLE.cmake @@ -16,14 +16,14 @@ endfunction() set(Test_PROP1 "Hello") set(Test_PROP2 "world") -set(Test_PROP3 "!") -define_property(TARGET PROPERTY PROP1 +set(MyTest_PROP3 "!") +define_property(TARGET PROPERTY Test_PROP1 INITIALIZE_FROM_VARIABLE Test_PROP1 ) add_subdirectory(define_property-INITIALIZE_FROM_VARIABLE-subdirectory) add_executable(top_exe main.c) -assert_prop_eq(top_exe PROP1 "Hello") -assert_prop_eq(top_exe PROP2 "world") -assert_prop_eq(top_exe PROP3 "!") +assert_prop_eq(top_exe Test_PROP1 "Hello") +assert_prop_eq(top_exe Test_PROP2 "world") +assert_prop_eq(top_exe Test_PROP3 "!") diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake index 8307bb2..400905c 100644 --- a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake @@ -63,7 +63,7 @@ if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode" endif() # Feature RESCAN -if (CMAKE_SYSTEM_NAME STREQUAL "Linux" +if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD" OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9")) OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) run_cmake(rescan) |