diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/lit/lit/Test.py | 11 | ||||
-rw-r--r-- | utils/lit/lit/llvm/config.py | 3 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-env/lit.cfg | 2 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt | 2 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-format/lit.cfg | 2 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-shell/dev-null.txt | 8 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-shell/lit.cfg | 2 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-shell/redirects.txt | 6 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-shell/valid-shell.txt | 28 | ||||
-rw-r--r-- | utils/lit/tests/Inputs/shtest-timeout/lit.cfg | 2 | ||||
-rw-r--r-- | utils/lit/tests/lit.cfg | 3 |
11 files changed, 38 insertions, 31 deletions
diff --git a/utils/lit/lit/Test.py b/utils/lit/lit/Test.py index 9fa9064dc689..a10419f33fa1 100644 --- a/utils/lit/lit/Test.py +++ b/utils/lit/lit/Test.py @@ -378,10 +378,15 @@ class Test: fil.write(testcase_xml) if self.result.code.isFailure: fil.write(">\n\t<failure ><![CDATA[") - if type(self.result.output) == unicode: - encoded_output = self.result.output.encode("utf-8", 'ignore') - else: + # In Python2, 'str' and 'unicode' are distinct types, but in Python3, the type 'unicode' does not exist + # and instead 'bytes' is distinct + # in Python3, there's no unicode + if isinstance(self.result.output, str): encoded_output = self.result.output + elif isinstance(self.result.output, bytes): + encoded_output = self.result.output.decode("utf-8", 'ignore') + else: + encoded_output = self.result.output.encode("utf-8", 'ignore') # In the unlikely case that the output contains the CDATA terminator # we wrap it by creating a new CDATA block fil.write(encoded_output.replace("]]>", "]]]]><![CDATA[>")) diff --git a/utils/lit/lit/llvm/config.py b/utils/lit/lit/llvm/config.py index 2257fb6db679..74c5f27c2790 100644 --- a/utils/lit/lit/llvm/config.py +++ b/utils/lit/lit/llvm/config.py @@ -299,7 +299,8 @@ class LLVMConfig(object): 'count'), verbatim=True, unresolved='fatal'), ToolSubst(r'\| \bnot\b', command=FindTool('not'), verbatim=True, unresolved='fatal')] - self.config.substitutions.append(('%python', sys.executable)) + self.config.substitutions.append(('%python', '"%s"' % (sys.executable))) + self.add_tool_substitutions( tool_patterns, [self.config.llvm_tools_dir]) diff --git a/utils/lit/tests/Inputs/shtest-env/lit.cfg b/utils/lit/tests/Inputs/shtest-env/lit.cfg index 23ef60a4b21e..1e2d050754a7 100644 --- a/utils/lit/tests/Inputs/shtest-env/lit.cfg +++ b/utils/lit/tests/Inputs/shtest-env/lit.cfg @@ -6,4 +6,4 @@ config.test_source_root = None config.test_exec_root = None config.environment['FOO'] = '1' config.environment['BAR'] = '2' -config.substitutions.append(('%{python}', sys.executable)) +config.substitutions.append(('%{python}', '"%s"' % (sys.executable))) diff --git a/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt b/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt index ce38831e32ed..7fbc7087a1a0 100644 --- a/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt +++ b/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt @@ -1,5 +1,5 @@ # Run a command that fails with error on stdout. # -# RUN: "%{python}" %S/write-bad-encoding.py +# RUN: %{python} %S/write-bad-encoding.py # RUN: false diff --git a/utils/lit/tests/Inputs/shtest-format/lit.cfg b/utils/lit/tests/Inputs/shtest-format/lit.cfg index 0d6488848b4f..607538e901a2 100644 --- a/utils/lit/tests/Inputs/shtest-format/lit.cfg +++ b/utils/lit/tests/Inputs/shtest-format/lit.cfg @@ -6,4 +6,4 @@ config.test_source_root = None config.test_exec_root = None config.target_triple = 'x86_64-unknown-unknown' config.available_features.add('a-present-feature') -config.substitutions.append(('%{python}', sys.executable)) +config.substitutions.append(('%{python}', "'%s'" % (sys.executable))) diff --git a/utils/lit/tests/Inputs/shtest-shell/dev-null.txt b/utils/lit/tests/Inputs/shtest-shell/dev-null.txt index 5b742489cc80..1561657085d4 100644 --- a/utils/lit/tests/Inputs/shtest-shell/dev-null.txt +++ b/utils/lit/tests/Inputs/shtest-shell/dev-null.txt @@ -1,14 +1,14 @@ # Check handling of /dev/null in command line options # On windows, it should be redirected to a temp file. # -# RUN: "%{python}" %S/check_args.py --my_arg /dev/null | FileCheck %s --check-prefix=CHECK1 +# RUN: %{python} %S/check_args.py --my_arg /dev/null | FileCheck %s --check-prefix=CHECK1 # CHECK1: OK -# RUN: "%{python}" %S/check_args.py --my_arg=/dev/null | FileCheck %s --check-prefix=CHECK2 +# RUN: %{python} %S/check_args.py --my_arg=/dev/null | FileCheck %s --check-prefix=CHECK2 # CHECK2: OK -# RUN: "%{python}" %S/check_args.py -a /dev/null | FileCheck %s --check-prefix=CHECK3 +# RUN: %{python} %S/check_args.py -a /dev/null | FileCheck %s --check-prefix=CHECK3 # CHECK3: OK -# RUN: "%{python}" %S/check_args.py -a=/dev/null | FileCheck %s --check-prefix=CHECK4 +# RUN: %{python} %S/check_args.py -a=/dev/null | FileCheck %s --check-prefix=CHECK4 # CHECK4: OK diff --git a/utils/lit/tests/Inputs/shtest-shell/lit.cfg b/utils/lit/tests/Inputs/shtest-shell/lit.cfg index 761dc6748855..3231dedc7146 100644 --- a/utils/lit/tests/Inputs/shtest-shell/lit.cfg +++ b/utils/lit/tests/Inputs/shtest-shell/lit.cfg @@ -4,4 +4,4 @@ config.suffixes = ['.txt'] config.test_format = lit.formats.ShTest() config.test_source_root = None config.test_exec_root = None -config.substitutions.append(('%{python}', sys.executable)) +config.substitutions.append(('%{python}', '"%s"' % (sys.executable))) diff --git a/utils/lit/tests/Inputs/shtest-shell/redirects.txt b/utils/lit/tests/Inputs/shtest-shell/redirects.txt index f90c2b7868b7..992ac9eb30aa 100644 --- a/utils/lit/tests/Inputs/shtest-shell/redirects.txt +++ b/utils/lit/tests/Inputs/shtest-shell/redirects.txt @@ -17,13 +17,13 @@ # Check stderr redirect (2> and 2>>). # # RUN: echo "not-present" > %t.stderr-write -# RUN: "%{python}" %S/write-to-stderr.py 2> %t.stderr-write +# RUN: %{python} %S/write-to-stderr.py 2> %t.stderr-write # RUN: FileCheck --check-prefix=STDERR-WRITE < %t.stderr-write %s # # STDERR-WRITE-NOT: not-present # STDERR-WRITE: a line on stderr # -# RUN: "%{python}" %S/write-to-stderr.py 2>> %t.stderr-write +# RUN: %{python} %S/write-to-stderr.py 2>> %t.stderr-write # RUN: FileCheck --check-prefix=STDERR-APPEND < %t.stderr-write %s # # STDERR-APPEND: a line on stderr @@ -33,7 +33,7 @@ # Check combined redirect (&>). # # RUN: echo "not-present" > %t.combined -# RUN: "%{python}" %S/write-to-stdout-and-stderr.py &> %t.combined +# RUN: %{python} %S/write-to-stdout-and-stderr.py &> %t.combined # RUN: FileCheck --check-prefix=COMBINED-WRITE < %t.combined %s # # COMBINED-WRITE-NOT: not-present diff --git a/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt b/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt index 6cc83e839cfb..7267b9b9ef5a 100644 --- a/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt +++ b/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt @@ -2,13 +2,13 @@ # Check force remove commands success whether the file does or doesn't exist. # # RUN: rm -f %t.write -# RUN: "%{python}" %S/check_path.py file %t.write > %t.out +# RUN: %{python} %S/check_path.py file %t.write > %t.out # RUN: FileCheck --check-prefix=REMOVE-FILE < %t.out %s # RUN: echo "create a temp file" > %t.write -# RUN: "%{python}" %S/check_path.py file %t.write > %t.out +# RUN: %{python} %S/check_path.py file %t.write > %t.out # RUN: FileCheck --check-prefix=FILE-EXIST < %t.out %s # RUN: rm -f %t.write -# RUN: "%{python}" %S/check_path.py file %t.write > %t.out +# RUN: %{python} %S/check_path.py file %t.write > %t.out # RUN: FileCheck --check-prefix=REMOVE-FILE < %t.out %s # # REMOVE-FILE: False @@ -19,14 +19,14 @@ # # Check the mkdir command with -p option. # RUN: rm -f -r %T/test -# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out +# RUN: %{python} %S/check_path.py dir %T/test > %t.out # RUN: FileCheck --check-prefix=REMOVE-PARENT-DIR < %t.out %s # RUN: mkdir -p %T/test -# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out +# RUN: %{python} %S/check_path.py dir %T/test > %t.out # RUN: FileCheck --check-prefix=MAKE-PARENT-DIR < %t.out %s # RUN: rm -f %T/test || true # RUN: rm -f -r %T/test -# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out +# RUN: %{python} %S/check_path.py dir %T/test > %t.out # RUN: FileCheck --check-prefix=REMOVE-PARENT-DIR < %t.out %s # # MAKE-PARENT-DIR: True @@ -36,13 +36,13 @@ # # RUN: rm -rf %T/test1 # RUN: mkdir %T/test1 -# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out +# RUN: %{python} %S/check_path.py dir %T/test1 > %t.out # RUN: FileCheck --check-prefix=MAKE-DIR < %t.out %s # RUN: cd %T/test1 && mkdir foo -# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out +# RUN: %{python} %S/check_path.py dir %T/test1 > %t.out # RUN: FileCheck --check-prefix=MAKE-DIR < %t.out %s # RUN: cd %T && rm -rf %T/test1 -# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out +# RUN: %{python} %S/check_path.py dir %T/test1 > %t.out # RUN: FileCheck --check-prefix=REMOVE-DIR < %t.out %s # # MAKE-DIR: True @@ -52,16 +52,16 @@ # # RUN: rm -rf %T/test # RUN: mkdir -p %T/test/test1 %T/test/test2 -# RUN: "%{python}" %S/check_path.py dir %T/test %T/test/test1 %T/test/test2 > %t.out +# RUN: %{python} %S/check_path.py dir %T/test %T/test/test1 %T/test/test2 > %t.out # RUN: FileCheck --check-prefix=DIRS-EXIST < %t.out %s # RUN: mkdir %T/test || true # RUN: echo "create a temp file" > %T/test/temp.write # RUN: echo "create a temp1 file" > %T/test/test1/temp1.write # RUN: echo "create a temp2 file" > %T/test/test2/temp2.write -# RUN: "%{python}" %S/check_path.py file %T/test/temp.write %T/test/test1/temp1.write %T/test/test2/temp2.write> %t.out +# RUN: %{python} %S/check_path.py file %T/test/temp.write %T/test/test1/temp1.write %T/test/test2/temp2.write> %t.out # RUN: FileCheck --check-prefix=FILES-EXIST < %t.out %s # RUN: rm -r -f %T/* -# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out +# RUN: %{python} %S/check_path.py dir %T/test > %t.out # RUN: FileCheck --check-prefix=REMOVE-ALL < %t.out %s # # DIRS-EXIST: True @@ -92,7 +92,7 @@ # RUN: mkdir -p %T/testCat # RUN: echo "abcdefgh" > %T/testCat/temp.write # RUN: cat %T/testCat/temp.write > %T/testCat/tempcat.write -# RUN: "%{python}" %S/check_path.py file %T/testCat/tempcat.write > %T/testCat/path.out +# RUN: %{python} %S/check_path.py file %T/testCat/tempcat.write > %T/testCat/path.out # RUN: FileCheck --check-prefix=FILE-EXISTS < %T/testCat/path.out %s # RUN: FileCheck --check-prefix=CAT-OUTPUT < %T/testCat/tempcat.write %s # FILE-EXISTS: True @@ -106,7 +106,7 @@ # RUN: echo "efghijkl" > %T/testCat/temp2.write # RUN: echo "mnopqrst" > %T/testCat/temp3.write # RUN: cat %T/testCat/temp1.write %T/testCat/temp2.write %T/testCat/temp3.write > %T/testCat/tempmulticat.write -# RUN: "%{python}" %S/check_path.py file %T/testCat/tempmulticat.write > %T/testCat/path.out +# RUN: %{python} %S/check_path.py file %T/testCat/tempmulticat.write > %T/testCat/path.out # RUN: FileCheck --check-prefix=MULTI-FILE-EXISTS < %T/testCat/path.out %s # RUN: FileCheck --check-prefix=MULTI-CAT-OUTPUT < %T/testCat/tempmulticat.write %s # MULTI-FILE-EXISTS: True diff --git a/utils/lit/tests/Inputs/shtest-timeout/lit.cfg b/utils/lit/tests/Inputs/shtest-timeout/lit.cfg index c3a1c3b96ada..96bf18170a8f 100644 --- a/utils/lit/tests/Inputs/shtest-timeout/lit.cfg +++ b/utils/lit/tests/Inputs/shtest-timeout/lit.cfg @@ -29,4 +29,4 @@ config.test_exec_root = config.test_source_root config.target_triple = '(unused)' src_root = os.path.join(config.test_source_root, '..') config.environment['PYTHONPATH'] = src_root -config.substitutions.append(('%{python}', sys.executable)) +config.substitutions.append(('%{python}', '"%s"' % (sys.executable))) diff --git a/utils/lit/tests/lit.cfg b/utils/lit/tests/lit.cfg index 75d1b5eac857..01a3431b4359 100644 --- a/utils/lit/tests/lit.cfg +++ b/utils/lit/tests/lit.cfg @@ -40,7 +40,8 @@ config.substitutions.append(('%{inputs}', os.path.join( src_root, 'tests', 'Inputs'))) config.substitutions.append(('%{lit}', "%%{python} %s" % ( os.path.join(lit_path, 'lit.py'),))) -config.substitutions.append(('%{python}', sys.executable)) +config.substitutions.append(('%{python}', '"%s"' % (sys.executable))) + # Enable coverage.py reporting, assuming the coverage module has been installed # and sitecustomize.py in the virtualenv has been modified appropriately. |