diff --git a/mmgen/data/version b/mmgen/data/version index efa6c01e..e989801d 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -14.0.dev2 +14.0.dev3 diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index fad15215..4413e3cb 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -19,7 +19,7 @@ def exec_wrapper_init(): exec_wrapper_sys.path[0] = 'test' else: from test.overlay import overlay_setup - exec_wrapper_sys.path[0] = overlay_setup(repo_root=os.getcwd()) # assume we're in the repo root + overlay_setup(repo_root=os.getcwd()) # assume we're in the repo root if 'TMUX' in os.environ: del os.environ['TMUX'] diff --git a/test/colortest.py b/test/colortest.py index 3f52be3e..dc78fd5f 100755 --- a/test/colortest.py +++ b/test/colortest.py @@ -7,7 +7,7 @@ test/colortest.py: test color handling for the MMGen suite """ -import include.tests_header +import include.test_init from include.common import * from mmgen.color import * import mmgen.color as color_mod diff --git a/test/gentest.py b/test/gentest.py index 675f74de..0f5d4b6f 100755 --- a/test/gentest.py +++ b/test/gentest.py @@ -22,9 +22,7 @@ test/gentest.py: Cryptocoin key/address generation tests for the MMGen suite import sys,os,time -from include.tests_header import repo_root -from test.overlay import overlay_setup -sys.path.insert(0,overlay_setup(repo_root)) +import include.test_init # Import these _after_ local path's been added to sys.path import mmgen.opts as opts diff --git a/test/hashfunc.py b/test/hashfunc.py index a0d15fdf..85d57f17 100755 --- a/test/hashfunc.py +++ b/test/hashfunc.py @@ -21,7 +21,7 @@ test/hashfunc.py: Test internal implementations of SHA256, SHA512 and Keccak256 """ import sys,os -import include.tests_header +import include.test_init from mmgen.util import die,ymsg assert len(sys.argv) in (2,3),"Test takes 1 or 2 arguments: test name, plus optional rounds count" diff --git a/test/include/coin_daemon_control.py b/test/include/coin_daemon_control.py index 241750db..1e431245 100755 --- a/test/include/coin_daemon_control.py +++ b/test/include/coin_daemon_control.py @@ -12,7 +12,7 @@ test.include.coin_daemon_control: Start and stop daemons for the MMGen test suite """ -from .tests_header import repo_root +import include.test_init from mmgen.common import * from mmgen.protocol import init_proto diff --git a/test/include/tests_header.py b/test/include/test_init.py similarity index 65% rename from test/include/tests_header.py rename to test/include/test_init.py index b8c793c6..caa501b5 100755 --- a/test/include/tests_header.py +++ b/test/include/test_init.py @@ -1,5 +1,8 @@ import sys,os os.environ['MMGEN_TEST_SUITE'] = '1' repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir))) +os.environ['PYTHONPATH'] = repo_root os.chdir(repo_root) sys.path[0] = repo_root +from test.overlay import overlay_setup +overlay_setup(repo_root) diff --git a/test/objattrtest.py b/test/objattrtest.py index f71d3cfa..8a51d554 100755 --- a/test/objattrtest.py +++ b/test/objattrtest.py @@ -24,7 +24,7 @@ test/objattrtest.py: Test immutable attributes of MMGen data objects import sys,os -from include.tests_header import repo_root +import include.test_init # Import these _after_ local path's been added to sys.path from mmgen.common import * diff --git a/test/objtest.py b/test/objtest.py index f99097a1..1befe2f0 100755 --- a/test/objtest.py +++ b/test/objtest.py @@ -22,9 +22,7 @@ test/objtest.py: Test MMGen data objects import sys,os,re -from include.tests_header import repo_root -from test.overlay import overlay_setup -sys.path.insert(0,overlay_setup(repo_root)) +import include.test_init from mmgen.devinit import init_dev init_dev() diff --git a/test/overlay/__init__.py b/test/overlay/__init__.py index 0df5dcc7..87528a8e 100644 --- a/test/overlay/__init__.py +++ b/test/overlay/__init__.py @@ -66,4 +66,6 @@ def overlay_setup(repo_root): for d in cfg.get('options','packages').split(): process_srcdir(pkgname,d) + sys.path.insert(0,overlay_tree_dir) + return overlay_tree_dir diff --git a/test/scrambletest.py b/test/scrambletest.py index 63c7279d..0668f196 100755 --- a/test/scrambletest.py +++ b/test/scrambletest.py @@ -24,7 +24,8 @@ test/scrambletest.py: seed scrambling and addrlist data generation tests for all import sys,os,time from subprocess import run,PIPE -from include.tests_header import repo_root +import include.test_init + import mmgen.opts as opts from mmgen.cfg import gc,Config from mmgen.util import msg,msg_r,bmsg diff --git a/test/test.py b/test/test.py index 7bddcc83..04dbe81e 100755 --- a/test/test.py +++ b/test/test.py @@ -72,18 +72,21 @@ def create_shm_dir(data_dir,trash_dir): import sys,os,time -from include.tests_header import repo_root -from test.overlay import get_overlay_tree_dir,overlay_setup - -overlay_tree_dir = get_overlay_tree_dir(repo_root) -sys.path.insert(0,overlay_tree_dir) - if sys.argv[-1] == 'clean': + os.environ['MMGEN_TEST_SUITE'] = '1' + repo_root = os.path.normpath(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),os.pardir))) + os.chdir(repo_root) + sys.path[0] = repo_root + from shutil import rmtree + from test.overlay import get_overlay_tree_dir + overlay_tree_dir = get_overlay_tree_dir(repo_root) rmtree(overlay_tree_dir,ignore_errors=True) + print(f'Removed {os.path.relpath(overlay_tree_dir)!r}') else: # overlay must be set up before importing mmgen mods! - overlay_setup(repo_root) + import include.test_init + repo_root = include.test_init.repo_root from mmgen.common import * diff --git a/test/tooltest.py b/test/tooltest.py index 4a309f86..98509afc 100755 --- a/test/tooltest.py +++ b/test/tooltest.py @@ -23,9 +23,7 @@ test/tooltest.py: Tests for the 'mmgen-tool' utility import sys,os,binascii from subprocess import run,PIPE -from include.tests_header import repo_root -from test.overlay import overlay_setup -sys.path.insert(0,overlay_setup(repo_root)) +import include.test_init from mmgen.common import * from test.include.common import * @@ -131,11 +129,9 @@ ref_subdir = '' if proto.base_coin == 'BTC' else proto.name.lower() altcoin_pfx = '' if proto.base_coin == 'BTC' else '-'+proto.base_coin tn_ext = ('','.testnet')[proto.testnet] -os.environ['PYTHONPATH'] = repo_root - spawn_cmd = [ 'scripts/exec_wrapper.py', - os.path.relpath(os.path.join(repo_root,'cmds','mmgen-tool')) ] + os.path.relpath(os.path.join(include.test_init.repo_root,'cmds','mmgen-tool')) ] if cfg.coverage: d,f = init_coverage() diff --git a/test/tooltest2.py b/test/tooltest2.py index a6233dc2..e7d37f19 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -27,9 +27,7 @@ import sys,os,time,importlib from subprocess import run,PIPE from decimal import Decimal -from include.tests_header import repo_root -from test.overlay import overlay_setup -sys.path.insert(0,overlay_setup(repo_root)) +import include.test_init from mmgen.common import * from test.include.common import set_globals,end_msg,sample_text @@ -970,7 +968,6 @@ if cfg.list_tested_cmds: list_tested_cmds() sys.exit(0) -os.environ['PYTHONPATH'] = repo_root tool_exec = os.path.relpath(os.path.join('cmds','mmgen-tool')) if cfg.fork: diff --git a/test/unit_tests.py b/test/unit_tests.py index de4b7e54..323a20e7 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -22,7 +22,7 @@ test/unit_tests.py: Unit tests for the MMGen suite import sys,os,time,importlib,platform -from include.tests_header import repo_root +import include.test_init from mmgen.devinit import init_dev init_dev() @@ -61,11 +61,9 @@ type(cfg)._reset_ok += ('use_internal_keccak_module','debug_addrlist') set_globals(cfg) -os.environ['PYTHONPATH'] = repo_root - file_pfx = 'ut_' -tests_d = os.path.join(repo_root,'test','unit_tests_d') +tests_d = os.path.join(include.test_init.repo_root,'test','unit_tests_d') all_tests = sorted(fn[len(file_pfx):-len('.py')] for fn in os.listdir(tests_d) if fn.startswith(file_pfx))