aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2018-08-31 16:23:08 +0000
committerMatthias Braun <matze@braunis.de>2018-08-31 16:23:08 +0000
commit0bf4fa5112454f7813edbaad2b97a718c840f955 (patch)
tree26a6c7b869a827c060c06da61af50730ad57cd9b
parent946e408de7507cf0e19e87ae5c95b6f3c007b670 (diff)
litsupport: fix pycodestyle/pyflakes reports; NFC
git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@341225 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--litsupport/modules/codesize.py14
-rw-r--r--litsupport/modules/hash.py3
-rw-r--r--litsupport/modules/microbenchmark.py14
-rw-r--r--litsupport/modules/remote.py3
-rw-r--r--litsupport/modules/timeit.py7
-rw-r--r--litsupport/shellcommand.py6
-rw-r--r--litsupport/test.py5
-rw-r--r--litsupport/testfile.py1
-rw-r--r--litsupport/testplan.py1
9 files changed, 27 insertions, 27 deletions
diff --git a/litsupport/modules/codesize.py b/litsupport/modules/codesize.py
index 9af9b9f2..f6599223 100644
--- a/litsupport/modules/codesize.py
+++ b/litsupport/modules/codesize.py
@@ -22,13 +22,13 @@ def _getCodeSize(context):
logging.warning("Unexpected output from llvm-size on '%s'",
context.executable)
else:
- for l in lines[2:]:
- l = l.strip()
- if l == "":
+ for line in lines[2:]:
+ line = line.strip()
+ if line == "":
continue
- values = l.split()
+ values = line.split()
if len(values) < 2:
- logging.info("Ignoring malformed output line: %s", l)
+ logging.info("Ignoring malformed output line: %s", line)
continue
if values[0] == 'Total':
continue
@@ -36,8 +36,8 @@ def _getCodeSize(context):
name = values[0]
val = int(values[1])
metrics['size.%s' % name] = val
- except ValueError as e:
- logging.info("Ignoring malformed output line: %s", l)
+ except ValueError:
+ logging.info("Ignoring malformed output line: %s", line)
return metrics
diff --git a/litsupport/modules/hash.py b/litsupport/modules/hash.py
index e8deb3f0..cf5e8616 100644
--- a/litsupport/modules/hash.py
+++ b/litsupport/modules/hash.py
@@ -1,5 +1,4 @@
"""Test module to collect test executable hashsum."""
-from litsupport import shellcommand
from litsupport import testplan
import hashlib
import logging
@@ -24,7 +23,7 @@ def compute(context):
h = hashlib.md5()
h.update(open(executable, 'rb').read())
context.executable_hash = h.hexdigest()
- except:
+ except Exception:
logging.info('Could not calculate hash for %s' % executable)
context.executable_hash = ''
diff --git a/litsupport/modules/microbenchmark.py b/litsupport/modules/microbenchmark.py
index 960e09b5..c7dc91a5 100644
--- a/litsupport/modules/microbenchmark.py
+++ b/litsupport/modules/microbenchmark.py
@@ -36,13 +36,17 @@ def _collectMicrobenchmarkTime(context, microbenchfiles):
microBenchmark = lit.Test.Result(lit.Test.PASS)
# Index 3 is cpu_time
- microBenchmark.addMetric('exec_time', lit.Test.toMetricValue(float(line[3])))
-
- # Add Micro Result
+ exec_time_metric = lit.Test.toMetricValue(float(line[3]))
+ microBenchmark.addMetric('exec_time', exec_time_metric)
+
+ # Add Micro Result
context.micro_results[name] = microBenchmark
- # returning the number of microbenchmarks collected as a metric for the base test
- return ({'MicroBenchmarks': lit.Test.toMetricValue(len(context.micro_results))})
+ # returning the number of microbenchmarks collected as a metric for the
+ # base test
+ return ({
+ 'MicroBenchmarks': lit.Test.toMetricValue(len(context.micro_results))
+ })
def mutatePlan(context, plan):
diff --git a/litsupport/modules/remote.py b/litsupport/modules/remote.py
index 7e93f5e0..6e8762a8 100644
--- a/litsupport/modules/remote.py
+++ b/litsupport/modules/remote.py
@@ -20,7 +20,8 @@ def _mutateCommandline(context, commandline, suffix=""):
def _mutateScript(context, script, suffix=""):
- mutate = lambda c, cmd: _mutateCommandline(c, cmd, suffix)
+ def mutate(context, command):
+ return _mutateCommandline(context, command, suffix)
return testplan.mutateScript(context, script, mutate)
diff --git a/litsupport/modules/timeit.py b/litsupport/modules/timeit.py
index bde2f0ec..1aebbbb7 100644
--- a/litsupport/modules/timeit.py
+++ b/litsupport/modules/timeit.py
@@ -81,9 +81,8 @@ def mutatePlan(context, plan):
def getUserTime(filename):
"""Extract the user time form a .time file produced by timeit"""
with open(filename) as fd:
- l = [l for l in fd.readlines()
- if l.startswith('user')]
- assert len(l) == 1
+ line = [line for line in fd.readlines() if line.startswith('user')]
+ assert len(line) == 1
- m = re.match(r'user\s+([0-9.]+)', l[0])
+ m = re.match(r'user\s+([0-9.]+)', line[0])
return float(m.group(1))
diff --git a/litsupport/shellcommand.py b/litsupport/shellcommand.py
index 7091f3ca..1431b0bf 100644
--- a/litsupport/shellcommand.py
+++ b/litsupport/shellcommand.py
@@ -5,7 +5,7 @@ import re
import os
try:
from shlex import quote # python 3.3 and above
-except:
+except ImportError:
from pipes import quote # python 3.2 and earlier
@@ -35,7 +35,6 @@ class ShellCommand:
res_list = [self.executable] + self.arguments
result += " ".join(map(quote, res_list))
- envlist = []
for key, value in self.envvars.items():
result += "%s=%s " % (key, quote(value))
@@ -71,7 +70,6 @@ def parse(commandline):
and switching directories upfront. It does not support full posix shell
and will throw an exception if the commandline uses unsupported features.
"""
- previous_commands = []
result = ShellCommand()
tokens = shlex.split(commandline)
i = 0
@@ -139,7 +137,7 @@ def getMainExecutable(context):
return context.executable
executable = None
- cwd = '.';
+ cwd = '.'
for line in context.parsed_runscript:
cmd = parse(line)
if cmd.workdir is not None:
diff --git a/litsupport/test.py b/litsupport/test.py
index 31c124f1..7ace75eb 100644
--- a/litsupport/test.py
+++ b/litsupport/test.py
@@ -10,7 +10,6 @@ import litsupport.modules
import litsupport.modules.hash
import litsupport.testfile
import litsupport.testplan
-import logging
import os
@@ -38,9 +37,9 @@ class TestSuiteTest(lit.formats.ShTest):
def execute(self, test, litConfig):
config = test.config
if config.unsupported:
- return lit.Test.Result(Test.UNSUPPORTED, 'Test is unsupported')
+ return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test is unsupported')
if litConfig.noExecute:
- return lit.Test.Result(Test.PASS)
+ return lit.Test.Result(lit.Test.PASS)
# Parse .test file and initialize context
tmpDir, tmpBase = lit.TestRunner.getTempPaths(test)
diff --git a/litsupport/testfile.py b/litsupport/testfile.py
index 9fa6b1c1..7e195457 100644
--- a/litsupport/testfile.py
+++ b/litsupport/testfile.py
@@ -2,6 +2,7 @@
from lit.TestRunner import parseIntegratedTestScriptCommands, \
getDefaultSubstitutions, applySubstitutions
from litsupport import shellcommand
+import logging
def _parseShellCommand(script, ln):
diff --git a/litsupport/testplan.py b/litsupport/testplan.py
index d4d619b6..3d27c975 100644
--- a/litsupport/testplan.py
+++ b/litsupport/testplan.py
@@ -1,7 +1,6 @@
"""
Datastructures for test plans; Parsing of .test files; Executing test plans.
"""
-from litsupport import shellcommand
import lit.Test
import lit.TestRunner
import logging