mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-14 18:51:42 -06:00
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:
11
Tests/RunCMake/execute_process/Encoding-common.cmake
Normal file
11
Tests/RunCMake/execute_process/Encoding-common.cmake
Normal file
@@ -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}
|
||||
)
|
||||
7
Tests/RunCMake/execute_process/Encoding-windows.cmake
Normal file
7
Tests/RunCMake/execute_process/Encoding-windows.cmake
Normal file
@@ -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}")
|
||||
@@ -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}")
|
||||
|
||||
2
Tests/RunCMake/execute_process/EncodingAUTO-stderr.txt
Normal file
2
Tests/RunCMake/execute_process/EncodingAUTO-stderr.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Chinese
|
||||
注意
|
||||
3
Tests/RunCMake/execute_process/EncodingAUTO.cmake
Normal file
3
Tests/RunCMake/execute_process/EncodingAUTO.cmake
Normal file
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user