summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-10-03 04:48:13 +0000
committerChris Bieneman <beanz@apple.com>2016-10-03 04:48:13 +0000
commitfc6e46a3141388d4ad394623bb58d1e30503ef69 (patch)
tree3c012b4d72f8ff4a996e1145c5a58cc8fc5da222
parentc9786f0d8a4db5f11442962907da2a4999ce8ec3 (diff)
downloadbcm5719-llvm-fc6e46a3141388d4ad394623bb58d1e30503ef69.tar.gz
bcm5719-llvm-fc6e46a3141388d4ad394623bb58d1e30503ef69.zip
[lit] Compare to None using identity, not equality
Summary: In Python, `None` is a singleton, so checking whether a variable is `None` may be done with `is` or `is not`. This has a slight advantage over equiality comparisons `== None` and `!= None`, since `__eq__` may be overridden in Python to produce sometimes unexpected results. Using `is None` and `is not None` is also recommended practice in https://www.python.org/dev/peps/pep-0008: > Comparisons to singletons like `None` should always be done with `is` or > `is not`, never the equality operators. Patch by Brian Gesiak! Reviewers: ddunbar, echristo, beanz Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D25168 llvm-svn: 283088
-rw-r--r--llvm/utils/lit/lit/TestRunner.py6
-rwxr-xr-xllvm/utils/lit/lit/main.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 24d687280c4..7c5683036a0 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -406,7 +406,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
data = f.read()
except:
data = None
- if data != None:
+ if data is not None:
output_files.append((name, path, data))
results.append(ShellCommandResult(
@@ -786,7 +786,7 @@ def _runShTest(test, litConfig, useExternalSh, script, tmpBase):
if exitCode == 0:
status = Test.PASS
else:
- if timeoutInfo == None:
+ if timeoutInfo is None:
status = Test.FAIL
else:
status = Test.TIMEOUT
@@ -795,7 +795,7 @@ def _runShTest(test, litConfig, useExternalSh, script, tmpBase):
output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
'\n'.join(script), exitCode)
- if timeoutInfo != None:
+ if timeoutInfo is not None:
output += """Timeout: %s\n""" % (timeoutInfo,)
output += "\n"
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 53f026dde18..82c863c8e9f 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -309,7 +309,7 @@ def main_with_tmp(builtinParameters):
userParams[name] = val
# Decide what the requested maximum indvidual test time should be
- if opts.maxIndividualTestTime != None:
+ if opts.maxIndividualTestTime is not None:
maxIndividualTestTime = opts.maxIndividualTestTime
else:
# Default is zero
@@ -340,7 +340,7 @@ def main_with_tmp(builtinParameters):
# After test discovery the configuration might have changed
# the maxIndividualTestTime. If we explicitly set this on the
# command line then override what was set in the test configuration
- if opts.maxIndividualTestTime != None:
+ if opts.maxIndividualTestTime is not None:
if opts.maxIndividualTestTime != litConfig.maxIndividualTestTime:
litConfig.note(('The test suite configuration requested an individual'
' test timeout of {0} seconds but a timeout of {1} seconds was'
OpenPOWER on IntegriCloud