Skip to content
Open
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
21 changes: 18 additions & 3 deletions pkgs/test_core/lib/src/util/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,26 @@ final _tempDir =
? Platform.environment['_UNITTEST_TEMP_DIR']!
: Directory.systemTemp.path;

/// Whether or not the current terminal supports ansi escape codes.
/// Whether [stdout] supports ANSI escape codes.
///
/// Otherwise only printable ASCII characters should be used.
bool get canUseSpecialChars =>
(!Platform.isWindows || stdout.supportsAnsiEscapes) && !inTestTests;
bool get canUseSpecialChars {
if (inTestTests) {
return false;
}

if (Platform.isWindows) {
return stdout.supportsAnsiEscapes;
}

// On Linux and Mac, `supportsAnsiEscapes` always returns `false` on most
// modern terminals, see https://github.com/dart-lang/sdk/issues/31606 for
// details.
//
// Instead of relying on `supportsAnsiEscapes`, we assume that all modern
// terminals support colors and check that `stdout` is a tty.
return stdioType(stdout) == StdioType.terminal;
}

/// Detect whether we're running in a Github Actions context.
///
Expand Down
Loading