Skip to content

Commit d9d655a

Browse files
committed
Fix new linting errors
We also modify `run-unittests` to run all the tox tests and linting, properly removing old tox environments before the runs.
1 parent 637cef8 commit d9d655a

File tree

7 files changed

+47
-14
lines changed

7 files changed

+47
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ dist
1010
.yarnrc
1111
*.egg-info
1212
.tox
13+
.eggs

lib/configtools/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
from optparse import OptionParser, make_option
1010

1111

12-
def uniq(l):
12+
def uniq(alist):
1313
# uniquify the list without scrambling it
1414
seen = set()
1515
seen_add = seen.add
16-
return [x for x in l if x not in seen and not seen_add(x)]
16+
return [el for el in alist if el not in seen and not seen_add(el)]
1717

1818

1919
def file_list(root):
@@ -168,8 +168,8 @@ def get(conf, option, sections):
168168
return None
169169

170170

171-
def print_list(l, sep):
172-
print(sep.join([str(x) for x in l]))
171+
def print_list(alist, sep):
172+
print(sep.join([str(el) for el in alist]))
173173

174174

175175
options = [

run-unittests

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
#!/bin/bash
22

3-
tox -e server
4-
tox -e agent
3+
prog="$(basename "${0}")"
4+
progdir="$(realpath -e $(dirname "${0}"))"
5+
6+
# List of tox environments to run.
7+
tox_envs="lint agent server"
8+
9+
for toxenv in ${tox_envs}; do
10+
if [[ -d ${progdir}/.tox/${toxenv} ]]; then
11+
rm -r ${progdir}/.tox/${toxenv}
12+
fi
13+
done
14+
15+
typeset -i errors=0
16+
for toxenv in ${tox_envs}; do
17+
printf -- "#+++ (tox -e %s)\n" "${toxenv}"
18+
tox -e ${toxenv}
19+
tox_status=${?}
20+
if [[ ${tox_status} -ne 0 ]]; then
21+
printf -- "#--- (FAILED: %d)\n" "${tox_status}"
22+
(( errors++ ))
23+
else
24+
printf -- "#--- (SUCCESS)\n"
25+
fi
26+
printf -- "\n\n"
27+
done
28+
29+
if [[ ${errors} -gt 0 ]]; then
30+
printf -- "\n\nUnit tests failed! (%d errors)\n" ${errors}
31+
exit 1
32+
else
33+
printf -- "\n\nUnit tests succeeded.\n"
34+
exit 0
35+
fi

server/bin/pbench-cull-unpacked-tarballs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def main(options):
453453
file=tfp,
454454
)
455455
if total > 0:
456-
print(f"\nActions Taken:", file=tfp)
456+
print("\nActions Taken:", file=tfp)
457457
for act_set in actions_taken:
458458
print(
459459
f" - {act_set.name} ({act_set.errors:d} errors,"

server/lib/pbench/indexer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3555,13 +3555,13 @@ def search_by_ip(sos_d_list, ip):
35553555
host_f = sos_d["hostname-f"]
35563556
except KeyError:
35573557
continue
3558-
for l in sos_d.values():
3559-
if not isinstance(l, list):
3558+
for el in sos_d.values():
3559+
if not isinstance(el, list):
35603560
continue
3561-
for d in l:
3562-
if not isinstance(d, dict):
3561+
for sub_el in el:
3562+
if not isinstance(sub_el, dict):
35633563
continue
3564-
if ip == d["ipaddr"]:
3564+
if ip == sub_el["ipaddr"]:
35653565
return host_f
35663566
return None
35673567

server/lib/pbench/mock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def put_template(self, *args, **kwargs):
5555
name = kwargs["name"]
5656
assert (
5757
name not in self.mock_collected_templates
58-
), "Duplicate template name, '{}'".format(name, self.name)
58+
), f"Duplicate template name, '{name}'"
5959
self.mock_collected_templates[name] = kwargs["body"]
6060
return None
6161

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ whitelist_externals =
2323

2424
[testenv:server]
2525
usedevelop = true
26+
passenv = PBENCH_UNITTEST_SERVER_MODE
2627
commands_pre =
2728
find {toxinidir} -type f -not -path '{toxinidir}/.tox/*' -path '*/__pycache__/*' -name '*.py[c|o]' -delete
2829
commands =
29-
bash -c "./server/bin/unittests"
30+
bash -c "./server/bin/unittests {posargs}"
3031

3132
[testenv:agent]
3233
usedevelop = true

0 commit comments

Comments
 (0)