Skip to content

Commit 1b25b6d

Browse files
author
MarcoFalke
committed
Merge #10097: Move zmq test skipping logic into individual test case.
6803e09 Move zmq test skipping logic into individual test case. (John Newbery) Tree-SHA512: 9d166b53e9acf386c4dafc860b38e2901b331a7505bba9714a2f4e3bdef68b0316c8b76fddbfb620835ddee549cf32fffb3a96a19b0799ad94f2553f55f19a35
2 parents c530c15 + 6803e09 commit 1b25b6d

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

test/functional/test_runner.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
'rawtransactions.py',
7878
'reindex.py',
7979
# vv Tests less than 30s vv
80+
"zmq_test.py",
8081
'mempool_resurrect_test.py',
8182
'txn_doublespend.py --mineblock',
8283
'txn_clone.py',
@@ -110,11 +111,6 @@
110111
'p2p-leaktests.py',
111112
]
112113

113-
ZMQ_SCRIPTS = [
114-
# ZMQ test can only be run if bitcoin was built with zmq-enabled.
115-
# call test_runner.py with -nozmq to explicitly exclude these tests.
116-
'zmq_test.py']
117-
118114
EXTENDED_SCRIPTS = [
119115
# These tests are not run by the travis build process.
120116
# Longest test should go first, to favor running tests in parallel
@@ -148,7 +144,7 @@
148144
]
149145

150146
# Place EXTENDED_SCRIPTS first since it has the 3 longest running tests
151-
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS + ZMQ_SCRIPTS
147+
ALL_SCRIPTS = EXTENDED_SCRIPTS + BASE_SCRIPTS
152148

153149
NON_SCRIPTS = [
154150
# These are python files that live in the functional tests directory, but are not test scripts.
@@ -173,7 +169,6 @@ def main():
173169
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
174170
parser.add_argument('--keepcache', '-k', action='store_true', help='the default behavior is to flush the cache directory on startup. --keepcache retains the cache from the previous testrun.')
175171
parser.add_argument('--quiet', '-q', action='store_true', help='only print results summary and failure logs')
176-
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
177172
args, unknown_args = parser.parse_known_args()
178173

179174
# Create a set to store arguments and create the passon string
@@ -191,7 +186,6 @@ def main():
191186
enable_wallet = config["components"].getboolean("ENABLE_WALLET")
192187
enable_utils = config["components"].getboolean("ENABLE_UTILS")
193188
enable_bitcoind = config["components"].getboolean("ENABLE_BITCOIND")
194-
enable_zmq = config["components"].getboolean("ENABLE_ZMQ") and not args.nozmq
195189

196190
if config["environment"]["EXEEXT"] == ".exe" and not args.force:
197191
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
@@ -204,27 +198,16 @@ def main():
204198
print("Rerun `configure` with -enable-wallet, -with-utils and -with-daemon and rerun make")
205199
sys.exit(0)
206200

207-
# python3-zmq may not be installed. Handle this gracefully and with some helpful info
208-
if enable_zmq:
209-
try:
210-
import zmq
211-
except ImportError:
212-
print("ERROR: \"import zmq\" failed. Use -nozmq to run without the ZMQ tests."
213-
"To run zmq tests, see dependency info in /test/README.md.")
214-
raise
215-
216201
# Build list of tests
217202
if tests:
218203
# Individual tests have been specified. Run specified tests that exist
219204
# in the ALL_SCRIPTS list. Accept the name with or without .py extension.
220205
test_list = [t for t in ALL_SCRIPTS if
221206
(t in tests or re.sub(".py$", "", t) in tests)]
222207
else:
223-
# No individual tests have been specified. Run base tests, and
224-
# optionally ZMQ tests and extended tests.
208+
# No individual tests have been specified.
209+
# Run all base tests, and optionally run extended tests.
225210
test_list = BASE_SCRIPTS
226-
if enable_zmq:
227-
test_list += ZMQ_SCRIPTS
228211
if args.extended:
229212
# place the EXTENDED_SCRIPTS first since the three longest ones
230213
# are there and the list is shorter

test/functional/zmq_test.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the ZMQ API."""
6+
import configparser
7+
import os
8+
import struct
9+
import sys
610

711
from test_framework.test_framework import BitcoinTestFramework
812
from test_framework.util import *
9-
import zmq
10-
import struct
1113

1214
class ZMQTest (BitcoinTestFramework):
1315

@@ -18,6 +20,21 @@ def __init__(self):
1820
port = 28332
1921

2022
def setup_nodes(self):
23+
# Try to import python3-zmq. Skip this test if the import fails.
24+
try:
25+
import zmq
26+
except ImportError:
27+
self.log.warning("python3-zmq module not available. Skipping zmq tests!")
28+
sys.exit(self.TEST_EXIT_SKIPPED)
29+
30+
# Check that bitcoin has been built with ZMQ enabled
31+
config = configparser.ConfigParser()
32+
config.read_file(open(os.path.dirname(__file__) + "/config.ini"))
33+
34+
if not config["components"].getboolean("ENABLE_ZMQ"):
35+
self.log.warning("bitcoind has not been built with zmq enabled. Skipping zmq tests!")
36+
sys.exit(self.TEST_EXIT_SKIPPED)
37+
2138
self.zmqContext = zmq.Context()
2239
self.zmqSubSocket = self.zmqContext.socket(zmq.SUB)
2340
self.zmqSubSocket.setsockopt(zmq.SUBSCRIBE, b"hashblock")

0 commit comments

Comments
 (0)