Tests: Generalize RunCMake.Ninja ShowIncludes test infrastructure

Prepare to add support for more languages.
This commit is contained in:
Brad King
2023-01-26 16:52:22 -05:00
parent c6dd4fa21d
commit 9596305c0b
10 changed files with 36 additions and 16 deletions

View File

@@ -46,8 +46,8 @@ if(WIN32)
if(RunCMake_MAKE_PROGRAM)
set(maybe_MAKE_PROGRAM "-DRunCMake_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
endif()
run_cmake_script(ShowIncludes-54936 -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
run_cmake_script(ShowIncludes-65001 -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
run_cmake_script(ShowIncludes-54936-Chinese -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
run_cmake_script(ShowIncludes-65001-Chinese -DshowIncludes=${showIncludes} ${maybe_MAKE_PROGRAM})
unset(maybe_MAKE_PROGRAM)
endif()

View File

@@ -1,2 +1,3 @@
set(CODEPAGE 54936)
set(VSLANG 2052)
include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes.cmake)

View File

@@ -1,2 +1,3 @@
set(CODEPAGE 65001)
set(VSLANG 2052)
include(${CMAKE_CURRENT_LIST_DIR}/ShowIncludes.cmake)

View File

@@ -1,6 +1,10 @@
# Set the console code page.
execute_process(COMMAND cmd /c chcp "${CODEPAGE}")
if(VSLANG)
set(ENV{VSLANG} "${VSLANG}")
endif()
if(RunCMake_MAKE_PROGRAM)
set(maybe_MAKE_PROGRAM "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
endif()

View File

@@ -15,7 +15,7 @@ endif()
# Run cmake in a new Window to isolate its console code page.
execute_process(COMMAND cmd /c start /min /wait ""
${CMAKE_COMMAND} -DCODEPAGE=${CODEPAGE} ${maybe_MAKE_PROGRAM} -P ${CMAKE_CURRENT_LIST_DIR}/ShowIncludes-cmake.cmake)
${CMAKE_COMMAND} -DCODEPAGE=${CODEPAGE} -DVSLANG=${VSLANG} ${maybe_MAKE_PROGRAM} -P ${CMAKE_CURRENT_LIST_DIR}/ShowIncludes-cmake.cmake)
# Print our internal UTF-8 representation of the showIncludes prefix.
file(READ "${CMAKE_CURRENT_BINARY_DIR}/showIncludes.txt" showIncludes_txt)

View File

@@ -1,33 +1,47 @@
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1928
# pragma warning(disable : 5105) /* macro expansion warning in windows.h */
#endif
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
/* 'cl /showIncludes' encodes output in the console output code page. */
unsigned int cp = GetConsoleOutputCP();
/* 'cl /showIncludes' prints output in the VS language. */
const char* vslang = getenv("VSLANG");
if (!vslang) {
fprintf(stderr, "VSLANG is not set.\n");
return 1;
}
printf("Console output code page: %u\n", cp);
printf("Console input code page: %u\n", GetConsoleCP());
printf("ANSI code page: %u\n", GetACP());
printf("OEM code page: %u\n", GetOEMCP());
printf("VSLANG: %s\n", vslang);
if (cp == 54936 || cp == 936) {
/* VSLANG=2052 */
printf("\xd7\xa2\xd2\xe2: "
"\xb0\xfc\xba\xac\xce\xc4\xbc\xfe: C:\\foo.h\n");
return 0;
if (strcmp(vslang, "2052") == 0) {
if (cp == 54936 || cp == 936) {
printf("\xd7\xa2\xd2\xe2: "
"\xb0\xfc\xba\xac\xce\xc4\xbc\xfe: C:\\foo.h\n");
return 0;
}
if (cp == 65001) {
printf("\xe6\xb3\xa8\xe6\x84\x8f: "
"\xe5\x8c\x85\xe5\x90\xab\xe6\x96\x87\xe4\xbb\xb6: C:\\foo.h\n");
return 0;
}
}
if (cp == 65001) {
/* VSLANG=2052 */
printf("\xe6\xb3\xa8\xe6\x84\x8f: "
"\xe5\x8c\x85\xe5\x90\xab\xe6\x96\x87\xe4\xbb\xb6: C:\\foo.h\n");
return 0;
}
fprintf(stderr, "No example showIncludes for console's output code page.\n");
fprintf(stderr, "No example showIncludes for this code page and VSLANG.\n");
return 1;
}