test suite: pexpect_spawn fixes

This commit is contained in:
The MMGen Project 2022-10-31 15:42:10 +00:00
commit 2fc54bd1e1
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 29 additions and 12 deletions

View file

@ -99,7 +99,7 @@ class TestSuiteCfg(TestSuiteBase):
e = CfgFileSampleUsr.altered_by_user_fs.format(self.path('sample'))
return self.bad_sample(s,e)
def old_sample_common(self,old_set=False,args=[],pexpect_spawn=None):
def old_sample_common(self,old_set=False,args=[],pexpect_spawn=False):
s = read_from_file(self.path('sys'))
d = s.replace('monero_','zcash_').splitlines()
a1 = ['','# Uncomment to make foo true:','# foo true']

View file

@ -86,12 +86,15 @@ class TestSuiteHelp(TestSuiteBase):
expect = kwargs.pop('expect')
t = self.spawn(*args,**kwargs)
t.expect(expect)
if t.pexpect_spawn:
time.sleep(0.4)
t.send('q')
t.read()
t.ok()
t.skip_ok = True
return t
def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:'):
def helpscreens(self,arg='--help',scripts=(),expect='USAGE:.*OPTIONS:',pager=True):
scripts = list(scripts) or [s.replace('mmgen-','') for s in os.listdir('cmds')]
@ -104,6 +107,9 @@ class TestSuiteHelp(TestSuiteBase):
for s in sorted(scripts):
t = self.spawn(f'mmgen-{s}',[arg],extra_desc=f'(mmgen-{s})')
t.expect(expect,regex=True)
if pager and t.pexpect_spawn:
time.sleep(0.2)
t.send('q')
t.read()
t.ok()
t.skip_ok = True
@ -120,7 +126,8 @@ class TestSuiteHelp(TestSuiteBase):
'walletgen','walletconv','walletchk','passchg','subwalletgen',
'addrgen','keygen','passgen',
'txsign','txdo','txbump'),
expect = 'Available parameters.*Preset' )
expect = 'Available parameters.*Preset',
pager = False )
def tool_help(self):

View file

@ -44,12 +44,14 @@ class TestSuiteOpts(TestSuiteBase):
return t
def opt_helpscreen(self):
return self.do_run(
['--help'],
r'OPTS.PY: Opts test.*USAGE:\s+opts.py.*--minconf.*'
+ r'NOTES FOR THIS.*a note',
0,
regex=True )
expect = r'OPTS.PY: Opts test.*USAGE:\s+opts.py'
if not opt.pexpect_spawn:
expect += r'.*--minconf.*NOTES FOR THIS.*a note'
t = self.do_run( ['--help'], expect, 0, regex=True )
if t.pexpect_spawn:
time.sleep(0.4)
t.send('q')
return t
def opt_noargs(self):
return self.check_vals(

View file

@ -708,8 +708,16 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
['--bob',f'--outdir={self.tmpdir}','txhist','age_fmt=date_time','interactive=true'] )
for resp in ('u','i','t','a','m','T','A','r','r','D','D','D','D','p','P','b','V'):
t.expect('draw:\b',resp,regex=True)
txnum,idx = (8,1) if self.proto.coin == 'BCH' else (9,3)
t.expect(f'\s{txnum}\).*Inputs:.*:L:{idx}.*Outputs \(3\):.*:C:2.*\s10\)','q',regex=True)
if t.pexpect_spawn:
t.expect(r'Block:.*\b394\b',regex=True)
time.sleep(1)
t.send('q')
time.sleep(0.2)
t.send('b')
t.expect('draw:\b','q',regex=True)
else:
txnum,idx = (8,1) if self.proto.coin == 'BCH' else (9,3)
t.expect(f'\s{txnum}\).*Inputs:.*:L:{idx}.*Outputs \(3\):.*:C:2.*\s10\)','q',regex=True)
return t
def bob_getbalance(self,bals,confs=1):
@ -1243,7 +1251,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
args = ['age_fmt=date_time'],
expect = (rtAmts[0],pat_date_time) )
def alice_txcreate_info(self,pexpect_spawn=None):
def alice_txcreate_info(self,pexpect_spawn=False):
t = self.spawn('mmgen-txcreate',['--alice','-Bi'],pexpect_spawn=pexpect_spawn)
pats = (
( '\d+', 'w'),