Index: utils/lit/lit/Test.py =================================================================== --- utils/lit/lit/Test.py +++ utils/lit/lit/Test.py @@ -378,7 +378,7 @@ fil.write(testcase_xml) if self.result.code.isFailure: fil.write(">\n\t (3,0) and mode == 'wb': + f.write(bytes('{ ' + '; } &&\n{ '.join(commands) + '; }', 'utf-8')) + else: + f.write('{ ' + '; } &&\n{ '.join(commands) + '; }') + f.write(b'\n' if mode == 'wb' else '\n') f.close() if isWin32CMDEXE: Index: utils/lit/lit/util.py =================================================================== --- utils/lit/lit/util.py +++ utils/lit/lit/util.py @@ -444,3 +444,21 @@ psutilProc.kill() except psutil.NoSuchProcess: pass + +def convertToLocalEncoding(text): + """This function converts utf-8 text into a format which the local system prefers + to work with. + """ + if platform.system() == 'Windows': + if sys.version_info < (3,0): + # On Windows and Python2, we want to use 'unicode' so it gets converted + # to UTF-16 + return text.decode('utf-8') if isinstance(text, str) else test + else: + # On Windows and Python3, we want to use a unicode string so it gets + # converted to UTF-16 + return text.decode('utf-8') if isinstance(text, bytes) else test + + # On non Windows, we just want bytes so python don't try to + # convert it to ascii + return text if isinstance(text, bytes) else test.encode('utf-8') Index: utils/lit/tests/Inputs/shtest-shell/rm-unicode-0.txt =================================================================== --- /dev/null +++ utils/lit/tests/Inputs/shtest-shell/rm-unicode-0.txt @@ -0,0 +1,7 @@ +# Check removing unicode +# +# RUN: mkdir -p Output/中文 +# RUN: echo "" > Output/中文/你好.txt +# RUN: rm Output/中文/你好.txt +# RUN: echo "" > Output/中文/你好.txt +# RUN: rm -r Output/中文 Index: utils/lit/tests/shtest-shell.py =================================================================== --- utils/lit/tests/shtest-shell.py +++ utils/lit/tests/shtest-shell.py @@ -224,6 +224,7 @@ # CHECK: Exit Code: 1 # CHECK: *** +# CHECK: PASS: shtest-shell :: rm-unicode-0.txt # CHECK: PASS: shtest-shell :: sequencing-0.txt # CHECK: XFAIL: shtest-shell :: sequencing-1.txt # CHECK: PASS: shtest-shell :: valid-shell.txt