Skip to content

Commit d86bb07

Browse files
author
MarcoFalke
committed
Merge #10197: [tests] Functional test warnings
08e51c1 [tests] Remove cache directory by default when running test_runner (John Newbery) c85b080 [test] add warnings to test_runner (John Newbery) Tree-SHA512: 537a8a258e410102708d1e02893f3f45abe7a3a3290536249381a7dc55d74ca78322804bf34178dec1461ec1c29d8f8358c5901ddd1633f8b301b95bcbb6ce6d
2 parents 50a1cc0 + 08e51c1 commit d86bb07

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/functional/test_runner.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def main():
171171
parser.add_argument('--force', '-f', action='store_true', help='run tests even on platforms where they are disabled by default (e.g. windows).')
172172
parser.add_argument('--help', '-h', '-?', action='store_true', help='print help text and exit')
173173
parser.add_argument('--jobs', '-j', type=int, default=4, help='how many test scripts to run in parallel. Default=4.')
174+
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.')
174175
parser.add_argument('--quiet', '-q', action='store_true', help='only print results summary and failure logs')
175176
parser.add_argument('--nozmq', action='store_true', help='do not run the zmq tests')
176177
args, unknown_args = parser.parse_known_args()
@@ -249,9 +250,23 @@ def main():
249250

250251
check_script_list(config["environment"]["SRCDIR"])
251252

253+
if not args.keepcache:
254+
shutil.rmtree("%s/test/cache" % config["environment"]["BUILDDIR"], ignore_errors=True)
255+
252256
run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args)
253257

254258
def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=False, args=[]):
259+
# Warn if bitcoind is already running (unix only)
260+
try:
261+
if subprocess.check_output(["pidof", "bitcoind"]) is not None:
262+
print("%sWARNING!%s There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0]))
263+
except (OSError, subprocess.SubprocessError):
264+
pass
265+
266+
# Warn if there is a cache directory
267+
cache_dir = "%s/test/cache" % build_dir
268+
if os.path.isdir(cache_dir):
269+
print("%sWARNING!%s There is a cache directory here: %s. If tests fail unexpectedly, try deleting the cache directory." % (BOLD[1], BOLD[0], cache_dir))
255270

256271
#Set env vars
257272
if "BITCOIND" not in os.environ:
@@ -260,7 +275,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
260275
tests_dir = src_dir + '/test/functional/'
261276

262277
flags = ["--srcdir={}/src".format(build_dir)] + args
263-
flags.append("--cachedir=%s/test/cache" % build_dir)
278+
flags.append("--cachedir=%s" % cache_dir)
264279

265280
if enable_coverage:
266281
coverage = RPCCoverage()
@@ -415,9 +430,10 @@ def check_script_list(src_dir):
415430
python_files = set([t for t in os.listdir(script_dir) if t[-3:] == ".py"])
416431
missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS)))
417432
if len(missed_tests) != 0:
418-
print("The following scripts are not being run:" + str(missed_tests))
419-
print("Check the test lists in test_runner.py")
420-
sys.exit(1)
433+
print("%sWARNING!%s The following scripts are not being run: %s. Check the test lists in test_runner.py." % (BOLD[1], BOLD[0], str(missed_tests)))
434+
if os.getenv('TRAVIS') == 'true':
435+
# On travis this warning is an error to prevent merging incomplete commits into master
436+
sys.exit(1)
421437

422438
class RPCCoverage(object):
423439
"""

0 commit comments

Comments
 (0)