Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,15 +480,26 @@ 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)"
)
Comment thread
Nerixyz marked this conversation as resolved.
return func

def unicode_wrapped(*args, **kwargs):
import os
Expand Down
6 changes: 5 additions & 1 deletion lldb/source/Host/common/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include <termios.h>
#endif

#ifdef _WIN32
#include "lldb/Host/windows/windows.h"
#endif

using namespace lldb_private;

struct Terminal::Data {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

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()
Expand Down Expand Up @@ -49,6 +52,9 @@ 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()
Expand Down