MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_tests

Function run_tests

test/functional/test_runner.py:523–639  ·  view source on GitHub ↗
(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, use_term_control)

Source from the content-addressed store, hash-verified

521 )
522
523def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=False, args=None, combined_logs_len=0, failfast=False, use_term_control):
524 args = args or []
525
526 # Warn if bitcoind is already running
527 try:
528 # pgrep exits with code zero when one or more matching processes found
529 if subprocess.run(["pgrep", "-x", "bitcoind"], stdout=subprocess.DEVNULL).returncode == 0:
530 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]))
531 except OSError:
532 # pgrep not supported
533 pass
534
535 # Warn if there is a cache directory
536 cache_dir = "%s/test/cache" % build_dir
537 if os.path.isdir(cache_dir):
538 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))
539
540 # Test Framework Tests
541 print("Running Unit Tests for Test Framework Modules")
542 test_framework_tests = unittest.TestSuite()
543 for module in TEST_FRAMEWORK_MODULES:
544 test_framework_tests.addTest(unittest.TestLoader().loadTestsFromName("test_framework.{}".format(module)))
545 result = unittest.TextTestRunner(verbosity=1, failfast=True).run(test_framework_tests)
546 if not result.wasSuccessful():
547 logging.debug("Early exiting after failure in TestFramework unit tests")
548 sys.exit(False)
549
550 tests_dir = src_dir + '/test/functional/'
551
552 flags = ['--cachedir={}'.format(cache_dir)] + args
553
554 if enable_coverage:
555 coverage = RPCCoverage()
556 flags.append(coverage.flag)
557 logging.debug("Initializing coverage directory at %s" % coverage.dir)
558 else:
559 coverage = None
560
561 if len(test_list) > 1 and jobs > 1:
562 # Populate cache
563 try:
564 subprocess.check_output([sys.executable, tests_dir + 'create_cache.py'] + flags + ["--tmpdir=%s/cache" % tmpdir])
565 except subprocess.CalledProcessError as e:
566 sys.stdout.buffer.write(e.output)
567 raise
568
569 #Run Tests
570 job_queue = TestHandler(
571 num_tests_parallel=jobs,
572 tests_dir=tests_dir,
573 tmpdir=tmpdir,
574 test_list=test_list,
575 flags=flags,
576 use_term_control=use_term_control,
577 )
578 start_time = time.time()
579 test_results = []
580

Callers 1

mainFunction · 0.70

Calls 10

get_nextMethod · 0.95
report_rpc_coverageMethod · 0.95
cleanupMethod · 0.95
formatMethod · 0.80
RPCCoverageClass · 0.70
TestHandlerClass · 0.70
print_resultsFunction · 0.70
runMethod · 0.45
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected