test.py: fixes for --pexpect-spawn
This commit is contained in:
parent
4453aaf355
commit
2660a3591b
6 changed files with 24 additions and 9 deletions
|
|
@ -657,6 +657,9 @@ class TestSuiteRunner(object):
|
|||
self.coverdir,self.accfile = init_coverage()
|
||||
omsg(f'INFO → Writing coverage files to {self.coverdir!r}')
|
||||
|
||||
if opt.pexpect_spawn:
|
||||
omsg(f'INFO → Using pexpect.spawn() for real terminal emulation')
|
||||
|
||||
def spawn_wrapper(self,cmd,
|
||||
args = [],
|
||||
extra_desc = '',
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ ref_enc_fn = 'sample-text.mmenc'
|
|||
tool_enc_passwd = "Scrypt it, don't hash it!"
|
||||
chksum_pat = r'\b[A-F0-9]{4} [A-F0-9]{4} [A-F0-9]{4} [A-F0-9]{4}\b'
|
||||
|
||||
Ctrl_U = '\x15'
|
||||
|
||||
def ok_msg():
|
||||
if opt.profile: return
|
||||
sys.stderr.write(green('\nOK\n') if opt.exact_output or opt.verbose else ' OK\n')
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ 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']
|
||||
|
|
|
|||
|
|
@ -320,6 +320,9 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
TestSuiteBase.__init__(self,trunner,cfgs,spawn)
|
||||
if trunner == None:
|
||||
return
|
||||
|
||||
self.erase_input = Ctrl_U if opt.pexpect_spawn else ''
|
||||
|
||||
from mmgen.protocol import init_proto
|
||||
self.proto = init_proto(g.coin,network='regtest')
|
||||
from mmgen.daemon import CoinDaemon
|
||||
|
|
@ -1121,11 +1124,11 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
t = self.spawn('mmgen-txcreate', self.eth_args + args + ['-B','-i'])
|
||||
p1,p2 = ('efresh balance:\b','return to main menu): ')
|
||||
p3,r3 = (p2,label_text+'\n') if label_text is not None else ('(y/N): ','y')
|
||||
p4,r4 = (('(y/N): ',),('y',)) if label_text == '' else ((),())
|
||||
p4,r4 = (('(y/N): ',),('y',)) if label_text == self.erase_input else ((),())
|
||||
for p,r in zip((p1,p1,p2,p3)+p4,('M',action,out_num+'\n',r3)+r4):
|
||||
t.expect(p,r)
|
||||
m = ( 'Account #{} removed' if action == 'D' else
|
||||
'Label added to account #{}' if label_text else
|
||||
'Label added to account #{}' if label_text and label_text != self.erase_input else
|
||||
'Label removed from account #{}' )
|
||||
t.expect(m.format(out_num))
|
||||
for p,r in zip((p1,p1),('M','q')):
|
||||
|
|
@ -1139,7 +1142,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
|
|||
def edit_label2(self):
|
||||
return self.edit_label(out_num=del_addrs[1],label_text=tw_label_lat_cyr_gr)
|
||||
def edit_label3(self):
|
||||
return self.edit_label(out_num=del_addrs[0],label_text='')
|
||||
return self.edit_label(out_num=del_addrs[0],label_text=self.erase_input)
|
||||
|
||||
def token_edit_label1(self):
|
||||
return self.edit_label(out_num='1',label_text='Token label #1',args=['--token=mm1'])
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class TestSuiteOutput(TestSuiteBase):
|
|||
def output_jp(self): return self.screen_output('jp')
|
||||
|
||||
def oneshot_warning(self):
|
||||
nl = '\r\n' if g.platform == 'win' else '\n'
|
||||
nl = '\r\n' if g.platform == 'win' or opt.pexpect_spawn else '\n'
|
||||
t = self.spawn('test/misc/oneshot_warning.py',cmd_dir='.')
|
||||
for s in (
|
||||
f'pw{nl}wg1',
|
||||
|
|
|
|||
|
|
@ -1020,11 +1020,16 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
|
|||
def alice_txcreate_info(self,args=[]):
|
||||
t = self.spawn('mmgen-txcreate',['--alice','-Bi'])
|
||||
pats = (
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( pat_date, 'w'),
|
||||
( '\d+\s+\d+\s+'+pat_date_time,'q'),
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( pat_date, 'q'),
|
||||
) if opt.pexpect_spawn else (
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( '\d+', 'D'),
|
||||
( pat_date, 'w'),
|
||||
( '\d+\s+\d+\s+'+pat_date_time,'q'),
|
||||
)
|
||||
for d,s in pats:
|
||||
t.expect(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue