diff options
author | Vasiliy Koyrev <ezqc123@gmail.com> | 2022-10-13 08:55:54 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-10-27 15:13:46 (GMT) |
commit | 9da542d5c1c983b9ea608b7fc04d75826278564f (patch) | |
tree | 27aadcd7ed112bf15d18311ab6fcff2d3dafe68b /Tests | |
parent | 2954a810ced784b04ec22bcdadb18bd73409c2a2 (diff) | |
download | CMake-9da542d5c1c983b9ea608b7fc04d75826278564f.zip CMake-9da542d5c1c983b9ea608b7fc04d75826278564f.tar.gz CMake-9da542d5c1c983b9ea608b7fc04d75826278564f.tar.bz2 |
string(TIMESTAMP): Add %z and %Z for adding time zone string
Fixes: #24056
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake | 22 | ||||
-rw-r--r-- | Tests/CMakeTests/StringTest.cmake.in | 3 | ||||
-rw-r--r-- | Tests/RunCMake/string/Timestamp-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/string/Timestamp.cmake | 2 |
4 files changed, 27 insertions, 2 deletions
diff --git a/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake b/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake new file mode 100644 index 0000000..eb2eb42 --- /dev/null +++ b/Tests/CMakeTests/String-TIMESTAMP-TimeZone.cmake @@ -0,0 +1,22 @@ +string(TIMESTAMP output "%z") + +STRING(LENGTH output output_length) + +message("~${output}~") + +set(expected_output_length 6) + +if(NOT(${output_length} EQUAL ${expected_output_length})) + message(FATAL_ERROR "expected ${expected_output_length} entries in output with all specifiers; found ${output_length}") +endif() + +string(SUBSTRING ${output} 0 1 output0) +string(SUBSTRING ${output} 4 1 output4) + +if(NOT((${output0} STREQUAL "-") OR (${output0} STREQUAL "+"))) + message(FATAL_ERROR "expected output[0] equ '+' or '-'; found: '${output0}'") +endif() + +if(NOT((${output4} STREQUAL "0") OR (${output4} STREQUAL "5"))) + message(FATAL_ERROR "expected output[4] equ '0' or '5'; found: '${output4}'") +endif() diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 154afa7..5f8b111 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -44,6 +44,8 @@ set(TIMESTAMP-IncompleteSpecifier-RESULT 0) set(TIMESTAMP-IncompleteSpecifier-STDERR "~foobar%~") set(TIMESTAMP-AllSpecifiers-RESULT 0) set(TIMESTAMP-AllSpecifiers-STDERR "~[0-9]+(;[0-9]+)*~") +set(TIMESTAMP-TimeZone-RESULT 0) +set(TIMESTAMP-TimeZone-STDERR "~[-,+][0-9][0-9][0-9][0-9]~") set(TIMESTAMP-MonthWeekNames-RESULT 0) set(TIMESTAMP-MonthWeekNames-STDERR "~[^%]+;[^%]+~") set(TIMESTAMP-UnixTime-RESULT 0) @@ -75,6 +77,7 @@ check_cmake_test(String TIMESTAMP-IncompleteSpecifier TIMESTAMP-AllSpecifiers TIMESTAMP-MonthWeekNames + TIMESTAMP-TimeZone TIMESTAMP-UnixTime ) diff --git a/Tests/RunCMake/string/Timestamp-stderr.txt b/Tests/RunCMake/string/Timestamp-stderr.txt index f162f52..c57bba6 100644 --- a/Tests/RunCMake/string/Timestamp-stderr.txt +++ b/Tests/RunCMake/string/Timestamp-stderr.txt @@ -1 +1 @@ -RESULT=2005-08-07 23:19:49.000000 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789 +^RESULT=2005-08-07 23:19:49.000000 Sunday=Sun August=Aug 05 day=219 wd=0 week=32 w_iso=31 %I=11 epoch=1123456789 TZ=GMT tz=\+0000$ diff --git a/Tests/RunCMake/string/Timestamp.cmake b/Tests/RunCMake/string/Timestamp.cmake index 531a237..3d68b1a 100644 --- a/Tests/RunCMake/string/Timestamp.cmake +++ b/Tests/RunCMake/string/Timestamp.cmake @@ -1,3 +1,3 @@ set(ENV{SOURCE_DATE_EPOCH} "1123456789") -string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S.%f %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s" UTC) +string(TIMESTAMP RESULT "%Y-%m-%d %H:%M:%S.%f %A=%a %B=%b %y day=%j wd=%w week=%U w_iso=%V %%I=%I epoch=%s TZ=%Z tz=%z" UTC) message("RESULT=${RESULT}") |