summaryrefslogtreecommitdiffstats
path: root/tests/test-runner/bin/test-runner.py
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2018-09-24 17:16:41 -0700
committerBrian Behlendorf <[email protected]>2018-09-24 17:20:42 -0700
commita7165d7255b71fea5a4b2431ccf915ee4099d613 (patch)
tree64543745658a578663d91bb24d105bcbedd72136 /tests/test-runner/bin/test-runner.py
parente897a23eb13bafcf9c38d2fc37ae57a7729d9a02 (diff)
Revert "Fix flake 8 style warnings"
This reverts commit b8fd4310c54444eecb66140d99a6156f4353b29b which accidentally introduced a regression for some versions of python. Signed-off-by: Brian Behlendorf <[email protected]> Issue #7929
Diffstat (limited to 'tests/test-runner/bin/test-runner.py')
-rwxr-xr-xtests/test-runner/bin/test-runner.py47
1 files changed, 23 insertions, 24 deletions
diff --git a/tests/test-runner/bin/test-runner.py b/tests/test-runner/bin/test-runner.py
index 9b4da75f7..a2b3830b4 100755
--- a/tests/test-runner/bin/test-runner.py
+++ b/tests/test-runner/bin/test-runner.py
@@ -16,7 +16,7 @@
# Copyright (c) 2017 Datto Inc.
#
-import configparser
+import ConfigParser
import os
import logging
from datetime import datetime
@@ -27,7 +27,7 @@ from select import select
from subprocess import PIPE
from subprocess import Popen
from sys import argv
-from sys import maxsize
+from sys import maxint
from threading import Timer
from time import time
@@ -204,23 +204,23 @@ class Cmd(object):
if needed. Run the command, and update the result object.
"""
if options.dryrun is True:
- print(self)
+ print self
return
privcmd = self.update_cmd_privs(self.pathname, self.user)
try:
old = os.umask(0)
if not os.path.isdir(self.outputdir):
- os.makedirs(self.outputdir, mode=0o777)
+ os.makedirs(self.outputdir, mode=0777)
os.umask(old)
- except OSError as e:
+ except OSError, e:
fail('%s' % e)
self.result.starttime = time()
proc = Popen(privcmd, stdout=PIPE, stderr=PIPE)
# Allow a special timeout value of 0 to mean infinity
if int(self.timeout) == 0:
- self.timeout = maxsize
+ self.timeout = maxint
t = Timer(int(self.timeout), self.kill_cmd, [proc])
try:
@@ -274,7 +274,7 @@ class Cmd(object):
logger.debug('%s%s%s' % (msga, pad, msgb))
lines = sorted(self.result.stdout + self.result.stderr,
- key=lambda x: x[0])
+ cmp=lambda x, y: cmp(x[0], y[0]))
for dt, line in lines:
logger.debug('%s %s' % (dt.strftime("%H:%M:%S.%f ")[:11], line))
@@ -552,7 +552,7 @@ class TestRun(object):
in the 'DEFAULT' section. If the Test or TestGroup passes
verification, add it to the TestRun.
"""
- config = configparser.RawConfigParser()
+ config = ConfigParser.RawConfigParser()
if not len(config.read(options.runfile)):
fail("Coulnd't read config file %s" % options.runfile)
@@ -608,7 +608,7 @@ class TestRun(object):
defaults = dict([(prop, getattr(options, prop)) for prop, _ in
self.defaults])
- config = configparser.RawConfigParser(defaults)
+ config = ConfigParser.RawConfigParser(defaults)
for test in sorted(self.tests.keys()):
config.add_section(test)
@@ -637,15 +637,14 @@ class TestRun(object):
"""
done = False
components = 0
- tmp_dict = dict(list(self.tests.items()) +
- list(self.testgroups.items()))
+ tmp_dict = dict(self.tests.items() + self.testgroups.items())
total = len(tmp_dict)
base = self.outputdir
while not done:
paths = []
components -= 1
- for testfile in list(tmp_dict.keys()):
+ for testfile in tmp_dict.keys():
uniq = '/'.join(testfile.split('/')[components:]).lstrip('/')
if uniq not in paths:
paths.append(uniq)
@@ -673,9 +672,9 @@ class TestRun(object):
if options.cmd is not 'wrconfig':
try:
old = os.umask(0)
- os.makedirs(self.outputdir, mode=0o777)
+ os.makedirs(self.outputdir, mode=0777)
os.umask(old)
- except OSError as e:
+ except OSError, e:
fail('%s' % e)
filename = os.path.join(self.outputdir, 'log')
@@ -708,8 +707,8 @@ class TestRun(object):
if not os.path.exists(logsymlink):
os.symlink(self.outputdir, logsymlink)
else:
- print('Could not make a symlink to directory %s' % (
- self.outputdir))
+ print 'Could not make a symlink to directory %s' % (
+ self.outputdir)
iteration = 0
while iteration < options.iterations:
for test in sorted(self.tests.keys()):
@@ -722,17 +721,17 @@ class TestRun(object):
if Result.total is 0:
return 2
- print('\nResults Summary')
- for key in list(Result.runresults.keys()):
+ print '\nResults Summary'
+ for key in Result.runresults.keys():
if Result.runresults[key] is not 0:
- print('%s\t% 4d' % (key, Result.runresults[key]))
+ print '%s\t% 4d' % (key, Result.runresults[key])
m, s = divmod(time() - self.starttime, 60)
h, m = divmod(m, 60)
- print('\nRunning Time:\t%02d:%02d:%02d' % (h, m, s))
- print('Percent passed:\t%.1f%%' % ((float(Result.runresults['PASS']) /
- float(Result.total)) * 100))
- print('Log directory:\t%s' % self.outputdir)
+ print '\nRunning Time:\t%02d:%02d:%02d' % (h, m, s)
+ print 'Percent passed:\t%.1f%%' % ((float(Result.runresults['PASS']) /
+ float(Result.total)) * 100)
+ print 'Log directory:\t%s' % self.outputdir
if Result.runresults['FAIL'] > 0:
return 1
@@ -805,7 +804,7 @@ def find_tests(testrun, options):
def fail(retstr, ret=1):
- print('%s: %s' % (argv[0], retstr))
+ print '%s: %s' % (argv[0], retstr)
exit(ret)