diff options
author | Tobias Bosch <tbosch@google.com> | 2019-08-19 11:00:19 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-08-19 20:57:25 +0000 |
commit | 4529f292ce64293d4650cc2be7caaa7e061196f5 (patch) | |
tree | cca7bd9ae8c7faafa5d0f7da353eac3573946638 /compiler_wrapper | |
parent | d8aa0d03924683c67577b6e0725f3f8a90dce0bc (diff) | |
download | toolchain-utils-4529f292ce64293d4650cc2be7caaa7e061196f5.tar.gz |
Support calling old wrapper with utf8 in stdout/stderr.
BUG=chromium:773875
TEST=unit tests, build glibc with compiler wrapper
Change-Id: I44df02ed46e72a10f444eb319ed8b51f0c6a3819
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1760972
Tested-by: Tobias Bosch <tbosch@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper')
-rw-r--r-- | compiler_wrapper/oldwrapper.go | 1 | ||||
-rw-r--r-- | compiler_wrapper/oldwrapper_test.go | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/compiler_wrapper/oldwrapper.go b/compiler_wrapper/oldwrapper.go index 3e42088a..1be4db5a 100644 --- a/compiler_wrapper/oldwrapper.go +++ b/compiler_wrapper/oldwrapper.go @@ -263,6 +263,7 @@ func callOldPythonWrapper(env env, cfg *oldWrapperConfig, inputCmd *command, fil defer os.Remove(mockFile.Name()) const mockTemplate = ` +# -*- coding: utf-8 -*- from __future__ import print_function class ListSet: diff --git a/compiler_wrapper/oldwrapper_test.go b/compiler_wrapper/oldwrapper_test.go index 37a3050e..a07615a9 100644 --- a/compiler_wrapper/oldwrapper_test.go +++ b/compiler_wrapper/oldwrapper_test.go @@ -247,6 +247,36 @@ func TestCompareToOldWrapperEscapeStdoutAndStderr(t *testing.T) { }) } +func TestCompareToOldWrapperSupportUtf8InStdoutAndStderr(t *testing.T) { + withTestContext(t, func(ctx *testContext) { + ctx.cfg.mockOldWrapperCmds = false + ctx.cfg.oldWrapperPath = filepath.Join(ctx.tempDir, "fakewrapper") + + ctx.cmdMock = func(cmd *command, stdin io.Reader, stdout io.Writer, stderr io.Writer) error { + io.WriteString(stdout, "©") + io.WriteString(stderr, "®") + writePythonMockWrapper(ctx, &mockWrapperConfig{ + Cmds: []*mockWrapperCmd{ + { + Path: cmd.Path, + Args: cmd.Args, + }, + }, + }) + return nil + } + + ctx.must(callCompiler(ctx, ctx.cfg, + ctx.newCommand(clangX86_64, mainCc))) + if ctx.stdoutString() != "©" { + t.Errorf("unexpected stdout. Got: %s", ctx.stdoutString()) + } + if ctx.stderrString() != "®" { + t.Errorf("unexpected stderr. Got: %s", ctx.stderrString()) + } + }) +} + func TestCompareToOldPythonWrapperArgumentsWithSpaces(t *testing.T) { withTestContext(t, func(ctx *testContext) { ctx.cfg.mockOldWrapperCmds = false |