Skip to content

Commit 117e0f2

Browse files
committed
Improve argument parsing in rpc-tests.py
- use --jobs instead of --parallel - construct passon_args and tests with list comprehension.
1 parent 0a49a41 commit 117e0f2

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

qa/pull-tester/rpc-tests.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,13 @@ def main():
132132
parser.add_argument('--extended', action='store_true', help='run the extended test suite in addition to the basic tests')
133133
parser.add_argument('--help', '-h', '-?', action='store_true', help='print help text and exit')
134134
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
135-
parser.add_argument('--parallel', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
135+
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
136136
parser.add_argument('--win', action='store_true', help='signal that this is running in a Windows environment and that we should run the tests')
137137
(args, unknown_args) = parser.parse_known_args()
138138

139139
# Create a set to store arguments and create the passon string
140-
tests = set()
141-
passon_args = []
142-
143-
for arg in unknown_args:
144-
if arg[:2] == "--":
145-
passon_args.append(arg)
146-
else:
147-
tests.add(arg)
140+
tests = set(arg for arg in unknown_args if arg[:2] != "--")
141+
passon_args = [arg for arg in unknown_args if arg[:2] == "--"]
148142

149143
# Read config generated by configure.
150144
config = configparser.ConfigParser()
@@ -176,17 +170,27 @@ def main():
176170
raise
177171

178172
# Build list of tests
179-
test_scripts = BASE_SCRIPTS
180-
if enable_zmq:
181-
test_scripts += ZMQ_SCRIPTS
182-
if args.extended:
183-
test_scripts += EXTENDED_SCRIPTS
173+
if len(tests) != 0:
174+
# Individual tests have been specified. Run specified tests that exist
175+
# in the ALL_SCRIPTS list. Accept the name with or without .py extension.
176+
test_list = [t for t in ALL_SCRIPTS if
177+
(t in tests or re.sub(".py$", "", t) in tests)]
178+
if len(test_list) == 0:
179+
print("No valid test scripts specified. Check that your test is in one "
180+
"of the test lists in rpc-tests.py or run rpc-tests.py with no arguments to run all tests")
181+
sys.exit(0)
184182

185-
if len(tests) == 0:
186-
test_list = test_scripts
187183
else:
188-
test_list = [t for t in test_scripts if
189-
(t in ALL_SCRIPTS or re.sub(".py$", "", t) in ALL_SCRIPTS)]
184+
# No individual tests have been specified. Run base tests, and
185+
# optionally ZMQ tests and extended tests.
186+
test_list = BASE_SCRIPTS
187+
if enable_zmq:
188+
test_list += ZMQ_SCRIPTS
189+
if args.extended:
190+
test_list += EXTENDED_SCRIPTS
191+
# TODO: BASE_SCRIPTS and EXTENDED_SCRIPTS are sorted by runtime
192+
# (for parallel running efficiency). This combined list will is no
193+
# longer sorted.
190194

191195
if args.help:
192196
# Print help for rpc-tests.py, then print help of the first script and exit.
@@ -199,7 +203,7 @@ def main():
199203
print(tests)
200204
sys.exit(0)
201205

202-
runtests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], args.parallel, args.coverage, passon_args)
206+
runtests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args)
203207

204208
def runtests(test_list, src_dir, build_dir, exeext, run_parallel=1, enable_coverage=False, args=[]):
205209
BOLD = ("","")

0 commit comments

Comments
 (0)