Skip to content

Commit c85b080

Browse files
committed
[test] add warnings to test_runner
1 parent b44adf9 commit c85b080

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

test/functional/test_runner.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ def main():
244244
run_tests(test_list, config["environment"]["SRCDIR"], config["environment"]["BUILDDIR"], config["environment"]["EXEEXT"], args.jobs, args.coverage, passon_args)
245245

246246
def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=False, args=[]):
247+
# Warn if bitcoind is already running (unix only)
248+
try:
249+
if subprocess.check_output(["pidof", "bitcoind"]) is not None:
250+
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]))
251+
except (OSError, subprocess.SubprocessError):
252+
pass
253+
254+
# Warn if there is a cache directory
255+
cache_dir = "%s/test/cache" % build_dir
256+
if os.path.isdir(cache_dir):
257+
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))
247258

248259
#Set env vars
249260
if "BITCOIND" not in os.environ:
@@ -252,7 +263,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
252263
tests_dir = src_dir + '/test/functional/'
253264

254265
flags = ["--srcdir={}/src".format(build_dir)] + args
255-
flags.append("--cachedir=%s/test/cache" % build_dir)
266+
flags.append("--cachedir=%s" % cache_dir)
256267

257268
if enable_coverage:
258269
coverage = RPCCoverage()
@@ -407,9 +418,10 @@ def check_script_list(src_dir):
407418
python_files = set([t for t in os.listdir(script_dir) if t[-3:] == ".py"])
408419
missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS)))
409420
if len(missed_tests) != 0:
410-
print("The following scripts are not being run:" + str(missed_tests))
411-
print("Check the test lists in test_runner.py")
412-
sys.exit(1)
421+
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)))
422+
if os.getenv('TRAVIS') == 'true':
423+
# On travis this warning is an error to prevent merging incomplete commits into master
424+
sys.exit(1)
413425

414426
class RPCCoverage(object):
415427
"""

0 commit comments

Comments
 (0)