aboutsummaryrefslogtreecommitdiff
path: root/qa/pull-tester
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-05-09 17:01:55 +0200
committerMarcoFalke <falke.marco@gmail.com>2016-05-09 17:06:44 +0200
commit4e14afe42fdd468d5de11df8cc13defdcb8e83f8 (patch)
tree4ebc19ab84c65fe2e161413ad8ae82dea6906986 /qa/pull-tester
parent3e90fe6534206412ea22beaa445cf20d28fbe718 (diff)
parentfad336648c848c7a4b3e32bae68ea9a22f97e668 (diff)
Merge #7971: [qa] Refactor test_framework and pull tester
fad3366 [qa] pull-tester: Adjust comment (MarcoFalke) fafb33c [qa] Stop other nodes, even when one fails to stop (MarcoFalke) 2222dae [qa] Update README.md (MarcoFalke) fabbf6b [qa] Refactor test_framework and pull tester (MarcoFalke)
Diffstat (limited to 'qa/pull-tester')
-rwxr-xr-xqa/pull-tester/rpc-tests.py82
1 files changed, 38 insertions, 44 deletions
diff --git a/qa/pull-tester/rpc-tests.py b/qa/pull-tester/rpc-tests.py
index 01c2736e66..10c3799b86 100755
--- a/qa/pull-tester/rpc-tests.py
+++ b/qa/pull-tester/rpc-tests.py
@@ -31,6 +31,14 @@ import re
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 = BUILDDIR + '/qa/rpc-tests/'
+
#If imported values are not defined then set to zero (or disabled)
if 'ENABLE_WALLET' not in vars():
ENABLE_WALLET=0
@@ -43,29 +51,29 @@ if 'ENABLE_ZMQ' not in vars():
ENABLE_COVERAGE=0
-#Create a set to store arguments and create the passOn string
+#Create a set to store arguments and create the passon string
opts = set()
-passOn = ""
-p = re.compile("^--")
+passon_args = ""
+PASSON_REGEX = re.compile("^--")
-bold = ("","")
-if (os.name == 'posix'):
- bold = ('\033[0m', '\033[1m')
+print_help = False
for arg in sys.argv[1:]:
+ if arg == "--help" or arg == "-h" or arg == "-?":
+ print_help = True
+ break
if arg == '--coverage':
ENABLE_COVERAGE = 1
- elif (p.match(arg) or arg == "-h"):
- passOn += " " + arg
+ elif PASSON_REGEX.match(arg):
+ passon_args += " " + arg
else:
opts.add(arg)
#Set env vars
-buildDir = BUILDDIR
if "BITCOIND" not in os.environ:
- os.environ["BITCOIND"] = buildDir + '/src/bitcoind' + EXEEXT
+ os.environ["BITCOIND"] = BUILDDIR + '/src/bitcoind' + EXEEXT
if "BITCOINCLI" not in os.environ:
- os.environ["BITCOINCLI"] = buildDir + '/src/bitcoin-cli' + EXEEXT
+ os.environ["BITCOINCLI"] = BUILDDIR + '/src/bitcoin-cli' + EXEEXT
if EXEEXT == ".exe" and "-win" not in opts:
# https://github.com/bitcoin/bitcoin/commit/d52802551752140cf41f0d9a225a43e84404d3e9
@@ -153,48 +161,34 @@ testScriptsExt = [
]
def runtests():
+ test_list = []
+ if '-extended' in opts:
+ test_list = testScripts + testScriptsExt
+ elif len(opts) == 0 or (len(opts) == 1 and "-win" in opts):
+ test_list = testScripts
+ else:
+ for t in testScripts + testScriptsExt:
+ if t in opts or re.sub(".py$", "", t) in opts:
+ test_list.append(t)
+
+ if print_help:
+ # Only print help of the first script and exit
+ subprocess.check_call(RPC_TESTS_DIR + test_list[0] + ' -h', shell=True)
+ sys.exit(0)
+
coverage = None
if ENABLE_COVERAGE:
coverage = RPCCoverage()
print("Initializing coverage directory at %s\n" % coverage.dir)
-
- rpcTestDir = buildDir + '/qa/rpc-tests/'
- run_extended = '-extended' in opts
- cov_flag = coverage.flag if coverage else ''
- flags = " --srcdir %s/src %s %s" % (buildDir, cov_flag, passOn)
+ flags = " --srcdir %s/src %s %s" % (BUILDDIR, coverage.flag if coverage else '', passon_args)
#Run Tests
- for i in range(len(testScripts)):
- if (len(opts) == 0
- or (len(opts) == 1 and "-win" in opts )
- or run_extended
- or testScripts[i] in opts
- or re.sub(".py$", "", testScripts[i]) in opts ):
-
- print("Running testscript %s%s%s ..." % (bold[1], testScripts[i], bold[0]))
- time0 = time.time()
- subprocess.check_call(
- rpcTestDir + testScripts[i] + flags, shell=True)
- print("Duration: %s s\n" % (int(time.time() - time0)))
-
- # exit if help is called so we print just one set of
- # instructions
- p = re.compile(" -h| --help")
- if p.match(passOn):
- sys.exit(0)
-
- # Run Extended Tests
- for i in range(len(testScriptsExt)):
- if (run_extended or testScriptsExt[i] in opts
- or re.sub(".py$", "", testScriptsExt[i]) in opts):
-
- print(
- "Running 2nd level testscript "
- + "%s%s%s ..." % (bold[1], testScriptsExt[i], bold[0]))
+ for t in test_list:
+ print("Running testscript %s%s%s ..." % (BOLD[1], t, BOLD[0]))
time0 = time.time()
subprocess.check_call(
- rpcTestDir + testScriptsExt[i] + flags, shell=True)
+ RPC_TESTS_DIR + t + flags, shell=True)
print("Duration: %s s\n" % (int(time.time() - time0)))
if coverage: