Index: llvm/trunk/utils/lit/lit/TestRunner.py =================================================================== --- llvm/trunk/utils/lit/lit/TestRunner.py +++ llvm/trunk/utils/lit/lit/TestRunner.py @@ -1133,9 +1133,12 @@ # Write script file mode = 'w' + open_kwargs = {} if litConfig.isWindows and not isWin32CMDEXE: - mode += 'b' # Avoid CRLFs when writing bash scripts. - f = open(script, mode) + mode += 'b' # Avoid CRLFs when writing bash scripts. + elif sys.version_info > (3,0): + open_kwargs['encoding'] = 'utf-8' + f = open(script, mode, **open_kwargs) if isWin32CMDEXE: for i, ln in enumerate(commands): commands[i] = re.sub(kPdbgRegex, "echo '\\1' > nul && ", ln) Index: llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt =================================================================== --- llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt +++ llvm/trunk/utils/lit/tests/Inputs/shtest-format/external_shell/utf8_command.txt @@ -0,0 +1,3 @@ +# Run a command including UTF-8 characters. +# +# RUN: echo £ Index: llvm/trunk/utils/lit/tests/shtest-format.py =================================================================== --- llvm/trunk/utils/lit/tests/shtest-format.py +++ llvm/trunk/utils/lit/tests/shtest-format.py @@ -80,7 +80,7 @@ # CHECK: shtest-format :: external_shell/fail_with_bad_encoding.txt # CHECK: shtest-format :: fail.txt -# CHECK: Expected Passes : 7 +# CHECK: Expected Passes : 8 # CHECK: Expected Failures : 4 # CHECK: Unsupported Tests : 5 # CHECK: Unresolved Tests : 3 @@ -90,7 +90,7 @@ # XUNIT: # XUNIT-NEXT: -# XUNIT-NEXT: +# XUNIT-NEXT: # XUNIT: