From 5f22ded0951f8937c651e4965831d05a074abdb2 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 2 Jun 2020 11:05:52 +0000 Subject: [PATCH] unit_tests.py: add --no-altcoin-deps option; update in test-release.sh --- test/test-release.sh | 6 +++--- test/unit_tests.py | 24 +++++++++++++++--------- test/unit_tests_d/ut_rpc.py | 2 ++ 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/test/test-release.sh b/test/test-release.sh index 9387ef20..2d21afa3 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -101,7 +101,7 @@ do echo echo " By default, all tests are run" exit ;; - A) SKIP_ALT=1 ;; + A) SKIP_ALT_DEP=1 unit_tests_py+=" --no-altcoin-deps";; b) test_py+=" --buf-keypress" ;; C) mkdir -p 'test/trace' touch 'test/trace.acc' @@ -153,7 +153,7 @@ case $1 in '') tests=$dfl_tests ;; 'default') tests=$dfl_tests ;; 'extra') tests=$extra_tests ;; - 'noalt') tests=$noalt_tests SKIP_ALT=1 ;; + 'noalt') tests=$noalt_tests SKIP_ALT_DEP=1 ;; 'quick') tests=$quick_tests ;; 'qskip') tests=$qskip_tests ;; *) tests="$*" ;; @@ -493,7 +493,7 @@ t_tool2=" $tooltest2_py --fork # run once with --fork so commands are actually executed " f_tool2='tooltest2 tests completed' -[ "$SKIP_ALT" ] && t_tool2_skip='17 18' +[ "$SKIP_ALT_DEP" ] && t_tool2_skip='17 18' i_tool='Tooltest' s_tool="The following tests will run '$tooltest_py' for all supported coins" diff --git a/test/unit_tests.py b/test/unit_tests.py index 81205e10..19defc82 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -30,14 +30,15 @@ opts_data = { 'desc': "Unit tests for the MMGen suite", 'usage':'[options] [test | test.subtest]...', 'options': """ --h, --help Print this help message +-h, --help Print this help message +-a, --no-altcoin-deps Skip tests requiring altcoin daemons, libs or utils -A, --no-daemon-autostart Don't start and stop daemons automatically --D, --no-daemon-stop Don't stop auto-started daemons after running tests --f, --fast Speed up execution by reducing rounds on some tests --l, --list List available tests --n, --names Print command names instead of descriptions --q, --quiet Produce quieter output --v, --verbose Produce more verbose output +-D, --no-daemon-stop Don't stop auto-started daemons after running tests +-f, --fast Speed up execution by reducing rounds on some tests +-l, --list List available tests +-n, --names Print command names instead of descriptions +-q, --quiet Produce quieter output +-v, --verbose Produce more verbose output """, 'notes': """ If no test is specified, all available tests are run @@ -52,7 +53,8 @@ def exit_msg(): t = int(time.time()) - start_time gmsg('All requested tests finished OK, elapsed time: {:02}:{:02}'.format(t//60,t%60)) -all_tests = [fn[3:-3] for fn in os.listdir(os.path.join(repo_root,'test','unit_tests_d')) if fn[:3] == 'ut_'] +all_tests = sorted( + [fn[3:-3] for fn in os.listdir(os.path.join(repo_root,'test','unit_tests_d')) if fn[:3] == 'ut_']) start_time = int(time.time()) @@ -97,10 +99,14 @@ def run_test(test,subtest=None): run_subtest(subtest) else: gmsg(f'Running unit test {test}') - if hasattr(mod,'unit_tests'): + if hasattr(mod,'unit_tests'): # new class-based API t = getattr(mod,'unit_tests') + altcoin_deps = getattr(t,'altcoin_deps',()) subtests = [k for k,v in t.__dict__.items() if type(v).__name__ == 'function'] for subtest in subtests: + if opt.no_altcoin_deps and subtest in altcoin_deps: + qmsg(gray(f'Invoked with --no-altcoin-deps, so skipping {subtest!r}')) + continue run_subtest(subtest) else: if not mod.unit_test().run_test(test,UnitTestHelpers): diff --git a/test/unit_tests_d/ut_rpc.py b/test/unit_tests_d/ut_rpc.py index 1cb02bad..7b406966 100755 --- a/test/unit_tests_d/ut_rpc.py +++ b/test/unit_tests_d/ut_rpc.py @@ -76,6 +76,8 @@ def run_test(coin,auth): class unit_tests: + altcoin_deps = ('bch','eth','xmr_wallet') + def bch(self,name,ut): return run_test('bch',auth=True)