Browse Source

test.py: log, error filename cleanups

The MMGen Project 1 year ago
parent
commit
a0ffe37a58
5 changed files with 12 additions and 12 deletions
  1. 0 4
      mmgen/help/__init__.py
  2. 2 1
      scripts/exec_wrapper.py
  3. 3 0
      test/include/common.py
  4. 7 5
      test/test.py
  5. 0 2
      test/test_py_d/common.py

+ 0 - 4
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()

+ 2 - 1
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' )

+ 3 - 0
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

+ 7 - 5
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
 

+ 0 - 2
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'