test.py cfg, test.include.pexpect: minor fix and cleanups

This commit is contained in:
The MMGen Project 2022-10-28 11:35:13 +00:00
commit 41474d9bf7
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 14 additions and 9 deletions

View file

@ -357,6 +357,8 @@ def init(
if not (opt.skip_cfg_file or opt.bob or opt.alice or g.prog_name == 'mmgen-regtest'):
from .cfg import cfg_file
# check for changes in system template file - term must be initialized
# workaround: g.test_suite is needed by cfg.py, but g is not set from environment yet
g.test_suite = False if os.getenv('MMGEN_TEST_SUITE') in (None,'','false','0') else True
cfg_file('sample')
override_globals_from_cfg_file( cfg_file('usr'), need_proto )

View file

@ -39,10 +39,14 @@ def debug_pexpect_msg(p):
NL = '\n'
class MMGenPexpect(object):
class MMGenPexpect:
def __init__(self,args,no_output=False,env=None):
self.req_exit_val = 0
self.skip_ok = False
self.sent_value = None
if opt.direct_exec:
msg('')
from subprocess import run,DEVNULL
@ -51,18 +55,12 @@ class MMGenPexpect(object):
timeout = int(opt.pexpect_timeout or 0) or (60,5)[bool(opt.debug_pexpect)]
if opt.pexpect_spawn:
self.p = pexpect.spawn(args[0],args[1:],encoding='utf8',timeout=timeout,env=env)
self.p.delaybeforesend = 0
else:
self.p = PopenSpawn(args,encoding='utf8',timeout=timeout,env=env)
# self.p.delaybeforesend = 0 # TODO: try this here too
if opt.exact_output:
self.p.logfile = sys.stdout
self.req_exit_val = 0
self.skip_ok = False
self.sent_value = None
def do_decrypt_ka_data(self,hp,pw,desc='key-address data',check=True,have_yes_opt=False):
# self.hash_preset(desc,hp)
self.passphrase(desc,pw)

View file

@ -99,8 +99,6 @@ class TestSuiteCfg(TestSuiteBase):
return self.bad_sample(s,e)
def old_sample_common(self,old_set=False,args=[]):
if opt.pexpect_spawn: # FIXME: get_char() is blocking
return 'skip'
s = read_from_file(self.path('sys'))
d = s.replace('monero_','zcash_').splitlines()
a1 = ['','# Uncomment to make foo true:','# foo true']
@ -126,6 +124,11 @@ class TestSuiteCfg(TestSuiteBase):
for s in ('CHANGES','Removed','# zcash_','# foo','# bar','Added','# monero_'):
t.expect(s)
if opt.pexpect_spawn: # view and exit pager
if opt.exact_output:
time.sleep(1)
t.send('q')
t.expect(cp,'n')
if old_set:

View file

@ -379,6 +379,8 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
if not self.using_solc:
omsg(yellow('Using precompiled contract data'))
omsg(blue(f'Coin daemon {self.daemon.id!r} selected'))
self.genesis_fn = joinpath(self.tmpdir,'genesis.json')
self.keystore_dir = os.path.relpath(joinpath(self.daemon.datadir,'keystore'))