From 038b201f6da469759c01e00c2576957447da762c Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 30 Aug 2023 13:27:29 -0700 Subject: [PATCH] Set PYTHONIOENCODING for all lit tests Rather than the one-off hack in `test-sourcekit-lsp.py`, just set the IO encoding to UTF8 for all tests. --- lit.cfg | 3 +++ test-sourcekit-lsp/test-sourcekit-lsp.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lit.cfg b/lit.cfg index 0491aef..7e3851c 100644 --- a/lit.cfg +++ b/lit.cfg @@ -96,6 +96,9 @@ if platform.system() == "Darwin": if 'XDG_CACHE_HOME' in os.environ: config.environment['XDG_CACHE_HOME'] = os.environ['XDG_CACHE_HOME'] +if sys.version_info[0] >= 3: + config.environment['PYTHONIOENCODING'] = 'UTF8' + ### # Use features like this in lit: diff --git a/test-sourcekit-lsp/test-sourcekit-lsp.py b/test-sourcekit-lsp/test-sourcekit-lsp.py index ddfe53c..76d7636 100644 --- a/test-sourcekit-lsp/test-sourcekit-lsp.py +++ b/test-sourcekit-lsp/test-sourcekit-lsp.py @@ -138,7 +138,7 @@ def main(): skargs = [args.sourcekit_lsp, '--sync', '-Xclangd', '-sync'] p = subprocess.Popen(skargs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, encoding='utf-8') out, _ = p.communicate(lsp.script) - print(out.encode(encoding='ascii', errors='replace')) + print(out) print('') if p.returncode == 0: