From a0ffe37a58e3297cd136ae998aecb856adf19be1 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 29 Sep 2023 12:24:21 +0000 Subject: [PATCH] test.py: log, error filename cleanups --- mmgen/help/__init__.py | 4 ---- scripts/exec_wrapper.py | 3 ++- test/include/common.py | 3 +++ test/test.py | 12 +++++++----- test/test_py_d/common.py | 2 -- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mmgen/help/__init__.py b/mmgen/help/__init__.py index df005a11..473e83b1 100755 --- a/mmgen/help/__init__.py +++ b/mmgen/help/__init__.py @@ -44,10 +44,6 @@ def help_notes_func(proto,cfg,k): from ..seedsplit import MasterShareIdx return MasterShareIdx - def test_py_log_file(): - from test.test_py_d.common import log_file - return log_file - def tool_help(): from ..tool.help import main_help return main_help() diff --git a/scripts/exec_wrapper.py b/scripts/exec_wrapper.py index c439110e..ef6e3654 100755 --- a/scripts/exec_wrapper.py +++ b/scripts/exec_wrapper.py @@ -66,7 +66,8 @@ def exec_wrapper_write_traceback(e,exit_val): sys.stdout.write('{}\n{}\n'.format( c.yellow( '\n'.join(tb_lines) ), c.red(exc_line) )) - with open('test.py.err','w') as fp: + from test.include.common import test_py_error_fn + with open(test_py_error_fn,'w') as fp: fp.write('\n'.join(tb_lines + [exc_line])) else: sys.stdout.write( c.purple((f'NONZERO_EXIT[{exit_val}]: ' if exit_val else '') + exc_line) + '\n' ) diff --git a/test/include/common.py b/test/include/common.py index 1b8e2e02..9f4d7e72 100755 --- a/test/include/common.py +++ b/test/include/common.py @@ -56,6 +56,9 @@ def strip_ansi_escapes(s): import re return re.sub('\x1b' + r'\[[;0-9]+?m','',s) +test_py_log_fn = 'test.py.log' +test_py_error_fn = 'test.py.err' + ascii_uc = ''.join(map(chr,list(range(65,91)))) # 26 chars ascii_lc = ''.join(map(chr,list(range(97,123)))) # 26 chars lat_accent = ''.join(map(chr,list(range(192,383)))) # 191 chars, L,S diff --git a/test/test.py b/test/test.py index 04dbe81e..190fcbbc 100755 --- a/test/test.py +++ b/test/test.py @@ -93,8 +93,10 @@ from mmgen.common import * from mmgen.devinit import init_dev init_dev() +from test.include.common import set_globals,test_py_log_fn,test_py_error_fn + try: - os.unlink(os.path.join(repo_root,'test.py.err')) + os.unlink(os.path.join(repo_root,test_py_error_fn)) except: pass @@ -165,7 +167,7 @@ environment var }, 'code': { 'options': lambda proto,help_notes,s: s.format( - lf = help_notes('test_py_log_file') + lf = test_py_log_fn ) } } @@ -173,7 +175,7 @@ environment var # we need some opt values before running opts.init, so parse without initializing: po = Config(opts_data=opts_data,parse_only=True)._parsed_opts -from test.include.common import set_globals,get_test_data_dir +from test.include.common import get_test_data_dir data_dir = get_test_data_dir() # include/common.py @@ -540,9 +542,9 @@ class TestSuiteRunner(object): self.deps_only = None if cfg.log: - self.log_fd = open(log_file,'a') + self.log_fd = open(test_py_log_fn,'a') self.log_fd.write(f'\nLog started: {make_timestr()} UTC\n') - omsg(f'INFO → Logging to file {log_file!r}') + omsg(f'INFO → Logging to file {test_py_log_fn!r}') else: self.log_fd = None diff --git a/test/test_py_d/common.py b/test/test_py_d/common.py index e1fd9772..e8f2fb7d 100755 --- a/test/test_py_d/common.py +++ b/test/test_py_d/common.py @@ -25,8 +25,6 @@ from mmgen.cfg import gc from mmgen.util import msg from ..include.common import * -log_file = 'test.py.log' - rt_pw = 'abc-α' ref_wallet_brainpass = 'abc' ref_wallet_hash_preset = '1'