diff options
| author | Aaron Smith <aaron.smith@microsoft.com> | 2018-04-07 00:21:28 +0000 | 
|---|---|---|
| committer | Aaron Smith <aaron.smith@microsoft.com> | 2018-04-07 00:21:28 +0000 | 
| commit | e5ee89c0d3efc1a7a34357d1d04e3d9e9f65d2be (patch) | |
| tree | ff14c818c5252a938abf3739ef5a9e5f3cbe89e1 /llvm/utils/lit | |
| parent | 045c514fb42515df05eb9bea3cac6a831da05ce7 (diff) | |
| download | bcm5719-llvm-e5ee89c0d3efc1a7a34357d1d04e3d9e9f65d2be.tar.gz bcm5719-llvm-e5ee89c0d3efc1a7a34357d1d04e3d9e9f65d2be.zip | |
[lit] Fix several Python 2/3 compatibility issues and tests
- In Python 2.x, basestring is the base string type, but in 
  Python 3.x basestring is not defined and instead str includes 
  unicode strings.
- When Python is in a path that includes spaces, it needs to 
  be specified with quotes in the test files for it to run.
- The cache.ll test relies on files of a specific size being 
  created by Python, but on some versions of Windows the 
  files that are created by the current code are one byte 
  larger than expected. To fix the test, update file creation 
  to always make files of the expected size.
Patch by Stella Stamenova!
llvm-svn: 329466
Diffstat (limited to 'llvm/utils/lit')
| -rw-r--r-- | llvm/utils/lit/lit/TestRunner.py | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 5eecb80e2f3..bfd15961ba0 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -845,8 +845,14 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):          # Replace uses of /dev/null with temporary files.          if kAvoidDevNull: +            # In Python 2.x, basestring is the base class for all string (including unicode) +            # In Python 3.x, basestring no longer exist and str is always unicode +            try: +                str_type = basestring +            except NameError: +                str_type = str              for i,arg in enumerate(args): -                if isinstance(arg, basestring) and kDevNull in arg: +                if isinstance(arg, str_type) and kDevNull in arg:                      f = tempfile.NamedTemporaryFile(delete=False)                      f.close()                      named_temp_files.append(f.name) | 

