From 90c1427af1291cdf2d85684574fe0033be87eef2 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 1 Nov 2024 14:34:53 -0700 Subject: [PATCH] Write run_tests console logs to stdout instead of stderr (flutter/engine#56312) Users of this script typically expect that the normal output of the tests will be written to stdout. However, the logging.StreamHandler writes to stderr by default unless another stream is specified. --- engine/src/flutter/testing/run_tests.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index de576890ef5..bac49efb536 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -23,7 +23,7 @@ import subprocess # Explicitly import the parts of sys that are needed. This is to avoid using # sys.stdout and sys.stderr directly. Instead, only the logger defined below # should be used for output. -from sys import exit as sys_exit, platform as sys_platform, path as sys_path +from sys import exit as sys_exit, platform as sys_platform, path as sys_path, stdout as sys_stdout import tempfile import time import typing @@ -45,7 +45,8 @@ ENCODING = 'UTF-8' LOG_FILE = os.path.join(OUT_DIR, 'run_tests.log') logger = logging.getLogger(__name__) -console_logger_handler = logging.StreamHandler() +# Write console logs to stdout (by default StreamHandler uses stderr) +console_logger_handler = logging.StreamHandler(sys_stdout) file_logger_handler = logging.FileHandler(LOG_FILE)