Tests/RunCMake/execute_process: Add test for ENCODING AUTO

On Windows the AUTO encoding is based on the console code page,
so run the test in an isolated console window.
This commit is contained in:
Brad King
2024-09-12 13:14:25 -04:00
parent 56ae758bc5
commit e1fc4b9b17
6 changed files with 37 additions and 5 deletions
@@ -0,0 +1,11 @@
if(ENCODING)
set(maybe_ENCODING ENCODING ${ENCODING})
else()
set(maybe_ENCODING "")
set(ENCODING AUTO) # execute_process's default ENCODING
endif()
execute_process(
COMMAND ${TEST_ENCODING_EXE} ${ENCODING} ${CMAKE_CURRENT_LIST_DIR}/Encoding${ENCODING}-stderr.txt
OUTPUT_VARIABLE out
${maybe_ENCODING}
)
@@ -0,0 +1,7 @@
# Set the console code page.
execute_process(COMMAND cmd /c chcp ${CODEPAGE})
include(${CMAKE_CURRENT_LIST_DIR}/Encoding-common.cmake)
# Save our internal UTF-8 representation of the output.
file(WRITE "out.txt" "${out}")
+13 -5
View File
@@ -1,6 +1,14 @@
execute_process(
COMMAND ${TEST_ENCODING_EXE} ${ENCODING} ${CMAKE_CURRENT_LIST_DIR}/Encoding${ENCODING}-stderr.txt
OUTPUT_VARIABLE out
ENCODING ${ENCODING}
)
if(CMAKE_HOST_WIN32 AND CODEPAGE)
# Run cmake in a new Window to isolate its console code page.
execute_process(COMMAND cmd /c start /min /wait ""
${CMAKE_COMMAND} -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE}
-DENCODING=${ENCODING}
-DCODEPAGE=${CODEPAGE}
-P ${CMAKE_CURRENT_LIST_DIR}/Encoding-windows.cmake)
# Load our internal UTF-8 representation of the output.
file(READ "out.txt" out)
else()
include(${CMAKE_CURRENT_LIST_DIR}/Encoding-common.cmake)
endif()
message("${out}")
@@ -0,0 +1,2 @@
Chinese
注意
@@ -0,0 +1,3 @@
set(ENCODING AUTO)
set(CODEPAGE 54936)
include(${CMAKE_CURRENT_LIST_DIR}/Encoding.cmake)
@@ -9,6 +9,7 @@ run_cmake_command(MergeOutputVars ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/Mer
run_cmake(EncodingMissing)
if(TEST_ENCODING_EXE)
run_cmake_script(EncodingAUTO -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
run_cmake_script(EncodingUTF-8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
run_cmake_script(EncodingUTF8 -DTEST_ENCODING_EXE=${TEST_ENCODING_EXE})
endif()