From 845470302dfb4aac5abf03adb54f21a2dfbcfd49 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 26 Sep 2023 09:37:13 +0000 Subject: [PATCH] test suite: remove --system option, minor cleanups --- test/scrambletest.py | 4 ---- test/test.py | 5 ----- test/tooltest.py | 12 ++++-------- test/tooltest2.py | 10 ++-------- test/unit_tests.py | 5 +++-- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/test/scrambletest.py b/test/scrambletest.py index cb7ca760..63c7279d 100755 --- a/test/scrambletest.py +++ b/test/scrambletest.py @@ -39,8 +39,6 @@ opts_data = { -a, --no-altcoin Skip altcoin tests -C, --coverage Produce code coverage info using trace module -l, --list-cmds List and describe the tests and commands in this test suite --s, --system Test scripts and modules installed on system rather than - those in the repo root -v, --verbose Produce more verbose output """, 'notes': """ @@ -101,8 +99,6 @@ cmd_base = f'python3{cvr_opts} cmds/mmgen-{{}}gen -qS' run_env = dict(os.environ) run_env['MMGEN_DEBUG_ADDRLIST'] = '1' -if not cfg.system: - run_env['PYTHONPATH'] = repo_root def get_cmd_output(cmd): cp = run( cmd.split(), stdout=PIPE, stderr=PIPE, env=run_env ) diff --git a/test/test.py b/test/test.py index 4754d67f..7bddcc83 100755 --- a/test/test.py +++ b/test/test.py @@ -141,8 +141,6 @@ opts_data = { -r, --resume=c Resume at command 'c' after interrupted run -R, --resume-after=c Same, but resume at command following 'c' -t, --step After resuming, execute one command and stop --s, --system Test scripts and modules installed on system rather - than those in the repo root -S, --skip-deps Skip dependency checking for command -u, --usr-random Get random data interactively from user -T, --pexpect-timeout=T Set the timeout for pexpect @@ -201,9 +199,6 @@ cfg.skipping_deps = cfg.resuming or 'skip_deps' in po.user_opts cmd_args = cfg._args -if not cfg.system: - os.environ['PYTHONPATH'] = repo_root - if cfg.pexpect_spawn and gc.platform == 'win': die(1,'--pexpect-spawn option not supported on Windows platform, exiting') diff --git a/test/tooltest.py b/test/tooltest.py index 71dd8e01..4a309f86 100755 --- a/test/tooltest.py +++ b/test/tooltest.py @@ -41,8 +41,6 @@ opts_data = { --, --longhelp Print help message for long options (common options) -l, --list-cmds List and describe the tests and commands in this test suite -L, --list-names List the names of all tested 'mmgen-tool' commands --s, --system Test scripts and modules installed on system rather than - those in the repo root -t, --type=t Specify address type (valid choices: 'zcash_z') -v, --verbose Produce more verbose output """, @@ -133,13 +131,11 @@ 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] -mmgen_cmd = 'mmgen-tool' +os.environ['PYTHONPATH'] = repo_root -if not cfg.system: - os.environ['PYTHONPATH'] = repo_root - mmgen_cmd = os.path.relpath(os.path.join(repo_root,'cmds',mmgen_cmd)) - -spawn_cmd = ['scripts/exec_wrapper.py',mmgen_cmd] +spawn_cmd = [ + 'scripts/exec_wrapper.py', + os.path.relpath(os.path.join(repo_root,'cmds','mmgen-tool')) ] if cfg.coverage: d,f = init_coverage() diff --git a/test/tooltest2.py b/test/tooltest2.py index fac59b97..a6233dc2 100755 --- a/test/tooltest2.py +++ b/test/tooltest2.py @@ -76,8 +76,6 @@ opts_data = { -L, --list-tested-cmds Output the 'mmgen-tool' commands that are tested by this test suite -n, --names Print command names instead of descriptions -q, --quiet Produce quieter output --s, --system Test scripts and modules installed on system rather than - those in the repo root -t, --type= Specify coin type -f, --fork Run commands via tool executable instead of importing tool module -v, --verbose Produce more verbose output @@ -972,12 +970,8 @@ if cfg.list_tested_cmds: list_tested_cmds() sys.exit(0) -if cfg.system: - tool_exec = 'mmgen-tool' - sys.path.pop(0) -else: - os.environ['PYTHONPATH'] = repo_root - tool_exec = os.path.relpath(os.path.join('cmds','mmgen-tool')) +os.environ['PYTHONPATH'] = repo_root +tool_exec = os.path.relpath(os.path.join('cmds','mmgen-tool')) if cfg.fork: passthru_args = ['coin','type','testnet','token'] diff --git a/test/unit_tests.py b/test/unit_tests.py index 2a4fb9e0..de4b7e54 100755 --- a/test/unit_tests.py +++ b/test/unit_tests.py @@ -65,8 +65,9 @@ os.environ['PYTHONPATH'] = repo_root file_pfx = 'ut_' -all_tests = sorted( - [fn[3:-3] for fn in os.listdir(os.path.join(repo_root,'test','unit_tests_d')) if fn[:3] == file_pfx]) +tests_d = os.path.join(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)) exclude = cfg.exclude.split(',') if cfg.exclude else []