Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
14 changes: 12 additions & 2 deletions tests/utils/stl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ def __init__(self, msg, out, err, exitCode):
kUseCloseFDs = not (platform.system() == 'Windows')


def decodeOutput(bytes):
# MSVC's output is encoded in the active code page
# EDG's (`cl /BE`) output is encoded in UTF-8
try:
return bytes.decode()
except UnicodeError:
import locale
return bytes.decode(locale.getpreferredencoding(do_setlocale=False))


def executeCommand(command, cwd=None, env=None, input=None, timeout=0):
"""
Execute command ``command`` (list of arguments or string)
Expand Down Expand Up @@ -118,8 +128,8 @@ def killProcess():
timerObject.cancel()

# Ensure the resulting output is always of string type.
out = out.decode()
err = err.decode()
out = decodeOutput(out)
err = decodeOutput(err)

if hitTimeOut:
raise ExecuteCommandTimeoutException(
Expand Down