Skip to content

Commit faa4f22

Browse files
author
MarcoFalke
committed
[qa] pull-tester: Exit early when no tests are run
1 parent fa05e22 commit faa4f22

File tree

1 file changed

+61
-63
lines changed

1 file changed

+61
-63
lines changed

qa/pull-tester/rpc-tests.py

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040
ENABLE_UTILS=0
4141
if 'ENABLE_ZMQ' not in vars():
4242
ENABLE_ZMQ=0
43-
44-
# python-zmq may not be installed. Handle this gracefully and with some helpful info
45-
if ENABLE_ZMQ:
46-
try:
47-
import zmq
48-
except ImportError as e:
49-
print("WARNING: \"import zmq\" failed. Set ENABLE_ZMQ=0 or " \
50-
"to run zmq tests, see dependency info in /qa/README.md.")
51-
raise e
5243

5344
ENABLE_COVERAGE=0
5445

@@ -76,11 +67,24 @@
7667
if "BITCOINCLI" not in os.environ:
7768
os.environ["BITCOINCLI"] = buildDir + '/src/bitcoin-cli' + EXEEXT
7869

79-
#Disable Windows tests by default
8070
if EXEEXT == ".exe" and "-win" not in opts:
81-
print "Win tests currently disabled. Use -win option to enable"
71+
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
72+
print "Win tests currently disabled by default. Use -win option to enable"
73+
sys.exit(0)
74+
75+
if not (ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
76+
print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
8277
sys.exit(0)
8378

79+
# python-zmq may not be installed. Handle this gracefully and with some helpful info
80+
if ENABLE_ZMQ:
81+
try:
82+
import zmq
83+
except ImportError as e:
84+
print("WARNING: \"import zmq\" failed. Set ENABLE_ZMQ=0 or " \
85+
"to run zmq tests, see dependency info in /qa/README.md.")
86+
raise e
87+
8488
#Tests
8589
testScripts = [
8690
'bip68-112-113-p2p.py',
@@ -119,6 +123,9 @@
119123
'p2p-versionbits-warning.py',
120124
'importprunedfunds.py',
121125
]
126+
if ENABLE_ZMQ:
127+
testScripts.append('zmq_test.py')
128+
122129
testScriptsExt = [
123130
'bip9-softforks.py',
124131
'bip65-cltv.py',
@@ -143,65 +150,56 @@
143150
'pruning.py', # leave pruning last as it takes a REALLY long time
144151
]
145152

146-
#Enable ZMQ tests
147-
if ENABLE_ZMQ == 1:
148-
testScripts.append('zmq_test.py')
149-
150-
151153
def runtests():
152154
coverage = None
153155

154156
if ENABLE_COVERAGE:
155157
coverage = RPCCoverage()
156158
print("Initializing coverage directory at %s\n" % coverage.dir)
157159

158-
if(ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
159-
rpcTestDir = buildDir + '/qa/rpc-tests/'
160-
run_extended = '-extended' in opts
161-
cov_flag = coverage.flag if coverage else ''
162-
flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
163-
164-
#Run Tests
165-
for i in range(len(testScripts)):
166-
if (len(opts) == 0
167-
or (len(opts) == 1 and "-win" in opts )
168-
or run_extended
169-
or testScripts[i] in opts
170-
or re.sub(".py$", "", testScripts[i]) in opts ):
171-
172-
print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
173-
time0 = time.time()
174-
subprocess.check_call(
175-
rpcTestDir + testScripts[i] + flags, shell=True)
176-
print("Duration: %s s\n" % (int(time.time() - time0)))
177-
178-
# exit if help is called so we print just one set of
179-
# instructions
180-
p = re.compile(" -h| --help")
181-
if p.match(passOn):
182-
sys.exit(0)
183-
184-
# Run Extended Tests
185-
for i in range(len(testScriptsExt)):
186-
if (run_extended or testScriptsExt[i] in opts
187-
or re.sub(".py$", "", testScriptsExt[i]) in opts):
188-
189-
print(
190-
"Running 2nd level testscript "
191-
+ "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
192-
time0 = time.time()
193-
subprocess.check_call(
194-
rpcTestDir + testScriptsExt[i] + flags, shell=True)
195-
print("Duration: %s s\n" % (int(time.time() - time0)))
196-
197-
if coverage:
198-
coverage.report_rpc_coverage()
199-
200-
print("Cleaning up coverage data")
201-
coverage.cleanup()
202-
203-
else:
204-
print "No rpc tests to run. Wallet, utils, and bitcoind must all be enabled"
160+
rpcTestDir = buildDir + '/qa/rpc-tests/'
161+
run_extended = '-extended' in opts
162+
cov_flag = coverage.flag if coverage else ''
163+
flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
164+
165+
#Run Tests
166+
for i in range(len(testScripts)):
167+
if (len(opts) == 0
168+
or (len(opts) == 1 and "-win" in opts )
169+
or run_extended
170+
or testScripts[i] in opts
171+
or re.sub(".py$", "", testScripts[i]) in opts ):
172+
173+
print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
174+
time0 = time.time()
175+
subprocess.check_call(
176+
rpcTestDir + testScripts[i] + flags, shell=True)
177+
print("Duration: %s s\n" % (int(time.time() - time0)))
178+
179+
# exit if help is called so we print just one set of
180+
# instructions
181+
p = re.compile(" -h| --help")
182+
if p.match(passOn):
183+
sys.exit(0)
184+
185+
# Run Extended Tests
186+
for i in range(len(testScriptsExt)):
187+
if (run_extended or testScriptsExt[i] in opts
188+
or re.sub(".py$", "", testScriptsExt[i]) in opts):
189+
190+
print(
191+
"Running 2nd level testscript "
192+
+ "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
193+
time0 = time.time()
194+
subprocess.check_call(
195+
rpcTestDir + testScriptsExt[i] + flags, shell=True)
196+
print("Duration: %s s\n" % (int(time.time() - time0)))
197+
198+
if coverage:
199+
coverage.report_rpc_coverage()
200+
201+
print("Cleaning up coverage data")
202+
coverage.cleanup()
205203

206204

207205
class RPCCoverage(object):

0 commit comments

Comments
 (0)