Browse Source

Use configparser in rpc-tests.py

Remove the use of wildcard imports in rpc-tests.py and replace with
configparser.
0.15
John Newbery 8 years ago
parent
commit
1581ecbc33
  1. 3
      Makefile.am
  2. 2
      configure.ac
  3. 33
      qa/pull-tester/rpc-tests.py
  4. 25
      qa/pull-tester/tests_config.ini.in
  5. 14
      qa/pull-tester/tests_config.py.in

3
Makefile.am

@ -227,9 +227,6 @@ EXTRA_DIST = $(top_srcdir)/share/genbuild.sh qa/pull-tester/rpc-tests.py qa/rpc-
CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER) CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER)
# This file is problematic for out-of-tree builds if it exists.
DISTCLEANFILES = qa/pull-tester/tests_config.pyc
.INTERMEDIATE: $(COVERAGE_INFO) .INTERMEDIATE: $(COVERAGE_INFO)
DISTCHECK_CONFIGURE_FLAGS = --enable-man DISTCHECK_CONFIGURE_FLAGS = --enable-man

2
configure.ac

@ -1087,7 +1087,7 @@ AC_SUBST(ZMQ_LIBS)
AC_SUBST(PROTOBUF_LIBS) AC_SUBST(PROTOBUF_LIBS)
AC_SUBST(QR_LIBS) AC_SUBST(QR_LIBS)
AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py]) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist src/test/buildenv.py])
AC_CONFIG_FILES([qa/pull-tester/tests_config.py],[chmod +x qa/pull-tester/tests_config.py]) AC_CONFIG_FILES([qa/pull-tester/tests_config.ini],[chmod +x qa/pull-tester/tests_config.ini])
AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh]) AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh])
AC_CONFIG_LINKS([qa/pull-tester/rpc-tests.py:qa/pull-tester/rpc-tests.py]) AC_CONFIG_LINKS([qa/pull-tester/rpc-tests.py:qa/pull-tester/rpc-tests.py])

33
qa/pull-tester/rpc-tests.py

@ -21,6 +21,7 @@ For a description of arguments recognized by test scripts, see
""" """
import configparser
import os import os
import time import time
import shutil import shutil
@ -29,26 +30,22 @@ import subprocess
import tempfile import tempfile
import re import re
sys.path.append("qa/pull-tester/")
from tests_config import *
BOLD = ("","") BOLD = ("","")
if os.name == 'posix': if os.name == 'posix':
# primitive formatting on supported # primitive formatting on supported
# terminal via ANSI escape sequences: # terminal via ANSI escape sequences:
BOLD = ('\033[0m', '\033[1m') 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"))
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"
#If imported values are not defined then set to zero (or disabled) RPC_TESTS_DIR = config["environment"]["SRCDIR"] + '/qa/rpc-tests/'
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_COVERAGE=0 ENABLE_COVERAGE=0
@ -76,15 +73,15 @@ for arg in sys.argv[1:]:
#Set env vars #Set env vars
if "BITCOIND" not in os.environ: 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/commit/d52802551752140cf41f0d9a225a43e84404d3e9
# https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964 # https://github.com/bitcoin/bitcoin/pull/5677#issuecomment-136646964
print("Win tests currently disabled by default. Use -win option to enable") print("Win tests currently disabled by default. Use -win option to enable")
sys.exit(0) 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") print("No rpc tests to run. Wallet, utils, and bitcoind must all be enabled")
sys.exit(0) sys.exit(0)
@ -209,8 +206,8 @@ def runtests():
if ENABLE_COVERAGE: if ENABLE_COVERAGE:
coverage = RPCCoverage() coverage = RPCCoverage()
print("Initializing coverage directory at %s\n" % coverage.dir) print("Initializing coverage directory at %s\n" % coverage.dir)
flags = ["--srcdir=%s/src" % BUILDDIR] + passon_args flags = ["--srcdir=%s/src" % config["environment"]["BUILDDIR"]] + passon_args
flags.append("--cachedir=%s/qa/cache" % BUILDDIR) flags.append("--cachedir=%s/qa/cache" % config["environment"]["BUILDDIR"])
if coverage: if coverage:
flags.append(coverage.flag) flags.append(coverage.flag)

25
qa/pull-tester/tests_config.ini.in

@ -0,0 +1,25 @@
# Copyright (c) 2013-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# These environment variables are set by the build process and read by
# rpc-tests.py
[DEFAULT]
# Provides default values for whether different components are enabled
ENABLE_WALLET=False
ENABLE_UTILS=False
ENABLE_BITCOIND=False
ENABLE_ZMQ=False
[environment]
SRCDIR=@abs_top_srcdir@
BUILDDIR=@abs_top_builddir@
EXEEXT=@EXEEXT@
[components]
# Which components are enabled. These are commented out by `configure` if they were disabled when running config.
@ENABLE_WALLET_TRUE@ENABLE_WALLET=True
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=True
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=True
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=True

14
qa/pull-tester/tests_config.py.in

@ -1,14 +0,0 @@
#!/usr/bin/env python3
# Copyright (c) 2013-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
SRCDIR="@abs_top_srcdir@"
BUILDDIR="@abs_top_builddir@"
EXEEXT="@EXEEXT@"
# These will turn into comments if they were disabled when configuring.
@ENABLE_WALLET_TRUE@ENABLE_WALLET=1
@BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=1
Loading…
Cancel
Save