[Lldb-commits] [lldb] [lldb][windows] re-enable unicode tests on Windows (PR #190828)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 7 10:58:22 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Charles Zablit (charles-zablit)
<details>
<summary>Changes</summary>
This patch re-enables unicode tests on Windows by improving the `Terminal::SupportsUnicode` check.
---
Full diff: https://github.com/llvm/llvm-project/pull/190828.diff
2 Files Affected:
- (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+14-4)
- (modified) lldb/source/Host/common/Terminal.cpp (+5-1)
``````````diff
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 8fd38c62f7b16..165833808dd2d 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -480,15 +480,25 @@ def unicode_test(func):
"""Decorate the item as a test which requires Unicode to be enabled.
lldb checks the value of the `LANG` environment variable for the substring "utf-8"
- to determine if the terminal supports Unicode (except on Windows, where we assume
- it's always supported).
+ to determine if the terminal supports Unicode (except on Windows, where stdout
+ being connected to an interactive console is used as the signal instead).
This decorator sets LANG to `utf-8` before running the test and resets it to its
previous value afterwards.
"""
if sys.platform == "win32":
- # Unicode support on Windows is flaky in CI.
- return expectedFailureWindows
+ import ctypes
+
+ STD_OUTPUT_HANDLE = -11
+ FILE_TYPE_CHAR = 0x0002
+ handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
+ file_type = ctypes.windll.kernel32.GetFileType(handle)
+ # Mirror Terminal::SupportsUnicode(): Unicode is supported only when
+ # stdout is connected to a real console.
+ if file_type != FILE_TYPE_CHAR:
+ return unittest.skip(
+ "Unicode test requires an interactive console (stderr is redirected)"
+ )
def unicode_wrapped(*args, **kwargs):
import os
diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp
index b6d09425e956e..2ddfb6fc3bebe 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -20,6 +20,10 @@
#include <termios.h>
#endif
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#endif
+
using namespace lldb_private;
struct Terminal::Data {
@@ -402,7 +406,7 @@ llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
bool Terminal::SupportsUnicode() {
#ifdef _WIN32
- return true;
+ return ::GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_CHAR;
#else
static std::optional<bool> g_result;
if (g_result)
``````````
</details>
https://github.com/llvm/llvm-project/pull/190828
More information about the lldb-commits
mailing list