[Lldb-commits] [lldb] [lldb][windows] re-enable unicode tests on Windows (PR #190828)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 10 09:59:04 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/190828

>From 3b14c3d7fdeec755b6be0918e94a330789c65e6e Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Tue, 7 Apr 2026 18:56:00 +0100
Subject: [PATCH 1/4] [lldb][windows] re-enable unicode tests on Windows

---
 .../Python/lldbsuite/test/decorators.py        | 18 ++++++++++++++----
 lldb/source/Host/common/Terminal.cpp           |  6 +++++-
 2 files changed, 19 insertions(+), 5 deletions(-)

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)

>From 6f8c0295aad9f7b314f6250a2cdeb41aa27b6f01 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 8 Apr 2026 11:53:33 +0100
Subject: [PATCH 2/4] fixup! [lldb][windows] re-enable unicode tests on Windows

---
 lldb/packages/Python/lldbsuite/test/decorators.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 165833808dd2d..a41fd62833a56 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -499,6 +499,7 @@ def unicode_test(func):
             return unittest.skip(
                 "Unicode test requires an interactive console (stderr is redirected)"
             )
+        return
 
     def unicode_wrapped(*args, **kwargs):
         import os

>From 980d8c97820fc6219cada2f5d04a8d8a562abdb6 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 10 Apr 2026 17:42:21 +0100
Subject: [PATCH 3/4] mark tests as expected failures

---
 lldb/packages/Python/lldbsuite/test/decorators.py               | 2 +-
 .../API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index a41fd62833a56..1ea984aa235cb 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -499,7 +499,7 @@ def unicode_test(func):
             return unittest.skip(
                 "Unicode test requires an interactive console (stderr is redirected)"
             )
-        return
+        return func
 
     def unicode_wrapped(*args, **kwargs):
         import os
diff --git a/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py b/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
index 50e648befa65b..346e1876a8bce 100644
--- a/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
+++ b/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
@@ -10,6 +10,7 @@
 
 class HiddenFrameMarkerTest(TestBase):
     @unicode_test
+    @expectedFailureWindows(bugnumber="https://github.com/llvm/llvm-project/issues/191459")
     def test_hidden_frame_markers(self):
         """Test that hidden frame markers are rendered in backtraces"""
         self.build()
@@ -49,6 +50,7 @@ def test_hidden_frame_markers(self):
         )
 
     @unicode_test
+    @expectedFailureWindows(bugnumber="https://github.com/llvm/llvm-project/issues/191459")
     def test_nested_hidden_frame_markers(self):
         """Test that nested hidden frame markers are rendered in backtraces"""
         self.build()

>From bb831e695b50c723a68ab946e45a25894af8b61d Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Fri, 10 Apr 2026 17:58:47 +0100
Subject: [PATCH 4/4] fixup! mark tests as expected failures

---
 .../hidden_frame_markers/TestHiddenFrameMarkers.py        | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py b/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
index 346e1876a8bce..b3c6627641775 100644
--- a/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
+++ b/lldb/test/API/terminal/hidden_frame_markers/TestHiddenFrameMarkers.py
@@ -10,7 +10,9 @@
 
 class HiddenFrameMarkerTest(TestBase):
     @unicode_test
-    @expectedFailureWindows(bugnumber="https://github.com/llvm/llvm-project/issues/191459")
+    @expectedFailureWindows(
+        bugnumber="https://github.com/llvm/llvm-project/issues/191459"
+    )
     def test_hidden_frame_markers(self):
         """Test that hidden frame markers are rendered in backtraces"""
         self.build()
@@ -50,7 +52,9 @@ def test_hidden_frame_markers(self):
         )
 
     @unicode_test
-    @expectedFailureWindows(bugnumber="https://github.com/llvm/llvm-project/issues/191459")
+    @expectedFailureWindows(
+        bugnumber="https://github.com/llvm/llvm-project/issues/191459"
+    )
     def test_nested_hidden_frame_markers(self):
         """Test that nested hidden frame markers are rendered in backtraces"""
         self.build()



More information about the lldb-commits mailing list