unit-test: Fix PEP8 E501 violations
E501: line too long (92 > 79 characters)
Change-Id: I1214289ffcda6979c5013e8c3afcbf84006260bf
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index f3a3f20..9344a83 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -511,7 +511,8 @@
path: The path to the package. Set to the working directory if None
"""
self.path = "." if not path else path
- self.package = package if package else os.path.basename(os.path.realpath(self.path))
+ realpath = os.path.realpath(self.path)
+ self.package = package if package else os.path.basename(realpath)
self.build_for_testing = False
def probe(self):
@@ -607,22 +608,22 @@
def dependencies(self):
configure_ac = os.path.join(self.path, 'configure.ac')
- configure_ac_contents = ''
+ contents = ''
# Prepend some special function overrides so we can parse out
# dependencies
for macro in DEPENDENCIES.iterkeys():
- configure_ac_contents += ('m4_define([' + macro + '], [' +
- macro + '_START$' +
- str(DEPENDENCIES_OFFSET[macro] + 1) +
- macro + '_END])\n')
+ contents += ('m4_define([' + macro + '], [' + macro + '_START$' +
+ str(DEPENDENCIES_OFFSET[macro] + 1) +
+ macro + '_END])\n')
with open(configure_ac, "rt") as f:
- configure_ac_contents += f.read()
+ contents += f.read()
- autoconf_process = subprocess.Popen(['autoconf', '-Wno-undefined', '-'],
+ autoconf_cmdline = ['autoconf', '-Wno-undefined', '-']
+ autoconf_process = subprocess.Popen(autoconf_cmdline,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- (stdout, stderr) = autoconf_process.communicate(input=configure_ac_contents)
+ (stdout, stderr) = autoconf_process.communicate(input=contents)
if not stdout:
print(stderr)
raise Exception("Failed to run autoconf for parsing dependencies")
@@ -750,8 +751,10 @@
continue
with open(os.path.join(root, 'meson.build'), 'rt') as f:
build_contents = f.read()
- for match in re.finditer(r"dependency\('([^']*)'.*?\)\n", build_contents):
- maybe_dep = DEPENDENCIES['PKG_CHECK_MODULES'].get(match.group(1))
+ pattern = r"dependency\('([^']*)'.*?\)\n"
+ for match in re.finditer(pattern, build_contents):
+ group = match.group(1)
+ maybe_dep = DEPENDENCIES['PKG_CHECK_MODULES'].get(group)
if maybe_dep is not None:
found_deps.append(maybe_dep)
@@ -808,13 +811,15 @@
else:
meson_flags.append('--buildtype=debugoptimized')
if 'tests' in meson_options:
- meson_flags.append('-Dtests=' + self._configure_feature(build_for_testing))
+ flag_args = self._configure_feature(build_for_testing)
+ meson_flags.append('-Dtests=' + flag_args)
if 'examples' in meson_options:
meson_flags.append('-Dexamples=' + str(build_for_testing).lower())
if MESON_FLAGS.get(self.package) is not None:
meson_flags.extend(MESON_FLAGS.get(self.package))
try:
- check_call_cmd('meson', 'setup', '--reconfigure', 'build', *meson_flags)
+ check_call_cmd('meson', 'setup', '--reconfigure', 'build',
+ *meson_flags)
except:
shutil.rmtree('build')
check_call_cmd('meson', 'setup', 'build', *meson_flags)
@@ -855,8 +860,8 @@
def _maybe_valgrind(self):
"""
Potentially runs the unit tests through valgrind for the package
- via `meson test`. The package can specify custom valgrind configurations
- by utilizing add_test_setup() in a meson.build
+ via `meson test`. The package can specify custom valgrind
+ configurations by utilizing add_test_setup() in a meson.build
"""
if not is_valgrind_safe():
sys.stderr.write("###### Skipping valgrind ######\n")
@@ -872,7 +877,8 @@
for root, _, files in os.walk(os.getcwd()):
if 'testlog-valgrind.txt' not in files:
continue
- check_call_cmd('cat', os.path.join(root, 'testlog-valgrind.txt'))
+ cat_args = os.path.join(root, 'testlog-valgrind.txt')
+ check_call_cmd('cat', cat_args)
raise Exception('Valgrind tests failed')
def analyze(self):