mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Use configparser in rpc-tests.py
Remove the use of wildcard imports in rpc-tests.py and replace with configparser.
This commit is contained in:
@@ -21,6 +21,7 @@ For a description of arguments recognized by test scripts, see
|
||||
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
@@ -29,26 +30,22 @@ import subprocess
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
sys.path.append("qa/pull-tester/")
|
||||
from tests_config import *
|
||||
|
||||
BOLD = ("","")
|
||||
if os.name == 'posix':
|
||||
# primitive formatting on supported
|
||||
# terminal via ANSI escape sequences:
|
||||
BOLD = ('\033[0m', '\033[1m')
|
||||
|
||||
RPC_TESTS_DIR = SRCDIR + '/qa/rpc-tests/'
|
||||
# Read config generated by configure.
|
||||
config = configparser.ConfigParser()
|
||||
config.read_file(open(os.path.dirname(__file__) + "/tests_config.ini"))
|
||||
|
||||
#If imported values are not defined then set to zero (or disabled)
|
||||
if 'ENABLE_WALLET' not in vars():
|
||||
ENABLE_WALLET=0
|
||||
if 'ENABLE_BITCOIND' not in vars():
|
||||
ENABLE_BITCOIND=0
|
||||
if 'ENABLE_UTILS' not in vars():
|
||||
ENABLE_UTILS=0
|
||||
if 'ENABLE_ZMQ' not in vars():
|
||||
ENABLE_ZMQ=0
|
||||
ENABLE_WALLET = config["components"]["ENABLE_WALLET"] == "True"
|
||||
ENABLE_UTILS = config["components"]["ENABLE_UTILS"] == "True"
|
||||
ENABLE_BITCOIND = config["components"]["ENABLE_BITCOIND"] == "True"
|
||||
ENABLE_ZMQ = config["components"]["ENABLE_ZMQ"] == "True"
|
||||
|
||||
RPC_TESTS_DIR = config["environment"]["SRCDIR"] + '/qa/rpc-tests/'
|
||||
|
||||
ENABLE_COVERAGE=0
|
||||
|
||||
@@ -76,15 +73,15 @@ for arg in sys.argv[1:]:
|
||||
|
||||
#Set env vars
|
||||
if "BITCOIND" not in os.environ:
|
||||
os.environ["BITCOIND"] = BUILDDIR + '/src/bitcoind' + EXEEXT
|
||||
os.environ["BITCOIND"] = config["environment"]["BUILDDIR"] + '/src/bitcoind' + config["environment"]["EXEEXT"]
|
||||
|
||||
if EXEEXT == ".exe" and "-win" not in opts:
|
||||
if config["environment"]["EXEEXT"] == ".exe" and "-win" not in opts:
|
||||
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
|
||||
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
|
||||
print("Win tests currently disabled by default. Use -win option to enable")
|
||||
sys.exit(0)
|
||||
|
||||
if not (ENABLE_WALLET == 1 and ENABLE_UTILS == 1 and ENABLE_BITCOIND == 1):
|
||||
if not (ENABLE_WALLET and ENABLE_UTILS and ENABLE_BITCOIND):
|
||||
print("No rpc tests to run. Wallet, utils, and bitcoind must all be enabled")
|
||||
sys.exit(0)
|
||||
|
||||
@@ -209,8 +206,8 @@ def runtests():
|
||||
if ENABLE_COVERAGE:
|
||||
coverage = RPCCoverage()
|
||||
print("Initializing coverage directory at %s\n" % coverage.dir)
|
||||
flags = ["--srcdir=%s/src" % BUILDDIR] + passon_args
|
||||
flags.append("--cachedir=%s/qa/cache" % BUILDDIR)
|
||||
flags = ["--srcdir=%s/src" % config["environment"]["BUILDDIR"]] + passon_args
|
||||
flags.append("--cachedir=%s/qa/cache" % config["environment"]["BUILDDIR"])
|
||||
if coverage:
|
||||
flags.append(coverage.flag)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user