Skip to content

Commit edefcd5

Browse files
committed
Merge bitcoin/bitcoin#29470: test: Add option to skip python unit tests
5f240ab test: Add option to skip unit tests for the test runner (Martin Zumsande) Pull request description: In the python `test_runner`, it's possible to disable specific functional tests (or just enable a few specific ones), but the unit tests for the python test framework cannot be skipped. Add this option (`--skipunit` or `-u`), it would save some time for devs not interested in running those every time. ACKs for top commit: fjahr: re-ACK 5f240ab tdb3: Code review and tested ACK 5f240ab stratospher: tested ACK 5f240ab. Tree-SHA512: f7c9cfefc18a6510e24ca4601309b40fdf4180a4c5fe592be9cf7607be6541784b283c46c8d6e60740ff3eba83025dd5d0db36e55bf8bad1404b38120859e113
2 parents eaede27 + 5f240ab commit edefcd5

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

test/functional/test_runner.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ def main():
434434
parser.add_argument('--tmpdirprefix', '-t', default=tempfile.gettempdir(), help="Root directory for datadirs")
435435
parser.add_argument('--failfast', '-F', action='store_true', help='stop execution after the first test failure')
436436
parser.add_argument('--filter', help='filter scripts to run by regular expression')
437+
parser.add_argument('--skipunit', '-u', action='store_true', help='skip unit tests for the test framework')
438+
437439

438440
args, unknown_args = parser.parse_known_args()
439441
if not args.ansi:
@@ -544,9 +546,10 @@ def main():
544546
combined_logs_len=args.combinedlogslen,
545547
failfast=args.failfast,
546548
use_term_control=args.ansi,
549+
skipunit=args.skipunit,
547550
)
548551

549-
def 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):
552+
def 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, skipunit=False):
550553
args = args or []
551554

552555
# Warn if bitcoind is already running
@@ -563,20 +566,20 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
563566
if os.path.isdir(cache_dir):
564567
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))
565568

566-
# Test Framework Tests
567-
print("Running Unit Tests for Test Framework Modules")
568569

569570
tests_dir = src_dir + '/test/functional/'
570571
# This allows `test_runner.py` to work from an out-of-source build directory using a symlink,
571572
# a hard link or a copy on any platform. See https://github.com/bitcoin/bitcoin/pull/27561.
572573
sys.path.append(tests_dir)
573574

574-
test_framework_tests = unittest.TestSuite()
575-
for module in TEST_FRAMEWORK_MODULES:
576-
test_framework_tests.addTest(unittest.TestLoader().loadTestsFromName("test_framework.{}".format(module)))
577-
result = unittest.TextTestRunner(verbosity=1, failfast=True).run(test_framework_tests)
578-
if not result.wasSuccessful():
579-
sys.exit("Early exiting after failure in TestFramework unit tests")
575+
if not skipunit:
576+
print("Running Unit Tests for Test Framework Modules")
577+
test_framework_tests = unittest.TestSuite()
578+
for module in TEST_FRAMEWORK_MODULES:
579+
test_framework_tests.addTest(unittest.TestLoader().loadTestsFromName("test_framework.{}".format(module)))
580+
result = unittest.TextTestRunner(verbosity=1, failfast=True).run(test_framework_tests)
581+
if not result.wasSuccessful():
582+
sys.exit("Early exiting after failure in TestFramework unit tests")
580583

581584
flags = ['--cachedir={}'.format(cache_dir)] + args
582585

0 commit comments

Comments
 (0)