Skip to content

Commit afd38e7

Browse files
committed
Improve rpc-tests.py arguments
A few miscellaneous improvements to rpc-tests.py command line arguments: - make all arguments start with double dash for consistency - improve help text and output - add nozmq argument to explicitly exclude the ZMQ tests - change 'parallel' to 'jobs'
1 parent 91bffff commit afd38e7

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

qa/pull-tester/rpc-tests.py

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,11 @@
22
# Copyright (c) 2014-2016 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5-
65
"""
7-
Run Regression Test Suite
6+
rpc-tests.py - run regression test suite
87
98
This module calls down into individual test cases via subprocess. It will
10-
forward all unrecognized arguments onto the individual test scripts, other
11-
than:
12-
13-
- `-extended`: run the "extended" test suite in addition to the basic one.
14-
- `-win`: signal that this is running in a Windows environment, and we
15-
should run the tests.
16-
- `--coverage`: this generates a basic coverage report for the RPC
17-
interface.
9+
forward all unrecognized arguments onto the individual test scripts.
1810
1911
For a description of arguments recognized by test scripts, see
2012
`qa/pull-tester/test_framework/test_framework.py:BitcoinTestFramework.main`.
@@ -32,12 +24,18 @@
3224
import re
3325

3426
# Parse arguments and pass through unrecognised args
35-
parser = argparse.ArgumentParser(add_help=False)
36-
parser.add_argument('--coverage', action='store_true')
37-
parser.add_argument('-extended', action='store_true')
38-
parser.add_argument('--help', '-h', '-?', action='store_true')
39-
parser.add_argument('--parallel', type=int, default=4)
40-
parser.add_argument('-win', action='store_true')
27+
parser = argparse.ArgumentParser(add_help=False,
28+
usage='%(prog)s [rpc-test.py options] [script options] [scripts]',
29+
description=__doc__,
30+
epilog='''
31+
Help text and arguments for individual test script:''',
32+
formatter_class=argparse.RawTextHelpFormatter)
33+
parser.add_argument('--coverage', action='store_true', help='generate a basic coverage report for the RPC interface')
34+
parser.add_argument('--extended', action='store_true', help='run the extended test suite in addition to the basic tests')
35+
parser.add_argument('--help', '-h', '-?', action='store_true', help='print help text and exit')
36+
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
37+
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
38+
parser.add_argument('--win', action='store_true', help='signal that this is running in a Windows environment and that we should run the tests')
4139
(args, unknown_args) = parser.parse_known_args()
4240

4341
#Create a set to store arguments and create the passon string
@@ -57,12 +55,12 @@
5755
ENABLE_WALLET = config["components"]["ENABLE_WALLET"] == "True"
5856
ENABLE_UTILS = config["components"]["ENABLE_UTILS"] == "True"
5957
ENABLE_BITCOIND = config["components"]["ENABLE_BITCOIND"] == "True"
60-
ENABLE_ZMQ = config["components"]["ENABLE_ZMQ"] == "True"
58+
ENABLE_ZMQ = config["components"]["ENABLE_ZMQ"] == "True" and not args.nozmq
6159

6260
RPC_TESTS_DIR = config["environment"]["SRCDIR"] + '/qa/rpc-tests/'
6361

6462
print_help = args.help
65-
run_parallel = args.parallel
63+
jobs = args.jobs
6664

6765
#Set env vars
6866
if "BITCOIND" not in os.environ:
@@ -71,7 +69,7 @@
7169
if config["environment"]["EXEEXT"] == ".exe" and not args.win:
7270
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
7371
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
74-
print("Win tests currently disabled by default. Use -win option to enable")
72+
print("Win tests currently disabled by default. Use --win option to enable")
7573
sys.exit(0)
7674

7775
if not (ENABLE_WALLET and ENABLE_UTILS and ENABLE_BITCOIND):
@@ -83,9 +81,8 @@
8381
try:
8482
import zmq
8583
except ImportError:
86-
print("ERROR: \"import zmq\" failed. Set ENABLE_ZMQ=0 or "
87-
"to run zmq tests, see dependency info in /qa/README.md.")
88-
# ENABLE_ZMQ=0
84+
print("ERROR: \"import zmq\" failed. Use -nozmq to run without the ZMQ tests."
85+
"To run zmq tests, see dependency info in /qa/README.md.")
8986
raise
9087

9188
BASE_SCRIPTS= [
@@ -202,7 +199,8 @@ def runtests():
202199
# longer sorted.
203200

204201
if args.help:
205-
# Only print help of the first script and exit
202+
# Print help for rpc-tests.py, then print help of the first script and exit.
203+
parser.print_help()
206204
subprocess.check_call((RPC_TESTS_DIR + test_list[0]).split() + ['-h'])
207205
sys.exit(0)
208206

@@ -216,15 +214,15 @@ def runtests():
216214
if coverage:
217215
flags.append(coverage.flag)
218216

219-
if len(test_list) > 1 and run_parallel > 1:
217+
if len(test_list) > 1 and jobs > 1:
220218
# Populate cache
221219
subprocess.check_output([RPC_TESTS_DIR + 'create_cache.py'] + flags)
222220

223221
#Run Tests
224222
max_len_name = len(max(test_list, key=len))
225223
time_sum = 0
226224
time0 = time.time()
227-
job_queue = RPCTestHandler(run_parallel, test_list, flags)
225+
job_queue = RPCTestHandler(jobs, test_list, flags)
228226
results = BOLD[1] + "%s | %s | %s\n\n" % ("TEST".ljust(max_len_name), "PASSED", "DURATION") + BOLD[0]
229227
all_passed = True
230228
for _ in range(len(test_list)):

0 commit comments

Comments
 (0)