ct_base: new skip_for_platform() method
This commit is contained in:
parent
b12a2a08a4
commit
4d0d7fc0e0
5 changed files with 18 additions and 10 deletions
|
|
@ -23,6 +23,7 @@ test.cmdtest_py_d.ct_base: Base class for the cmdtest.py test suite
|
|||
import sys,os
|
||||
|
||||
from mmgen.util import msg
|
||||
from mmgen.color import gray
|
||||
|
||||
from ..include.common import cfg,write_to_file,read_from_file
|
||||
from .common import get_file_with_ext
|
||||
|
|
@ -38,6 +39,7 @@ class CmdTestBase:
|
|||
need_daemon = False
|
||||
win_skip = False
|
||||
tmpdir_nums = []
|
||||
test_name = None
|
||||
|
||||
def __init__(self,trunner,cfgs,spawn):
|
||||
if hasattr(self,'name'): # init will be called multiple times for classes with multiple inheritance
|
||||
|
|
@ -82,13 +84,19 @@ class CmdTestBase:
|
|||
except:
|
||||
msg(f'{fn}: file does not exist or could not be deleted')
|
||||
|
||||
def skip_for_win(self):
|
||||
if sys.platform == 'win32':
|
||||
msg(f'Skipping test {self.test_name!r}: not supported on MSys2 platform')
|
||||
def skip_for_platform(self, name, extra_msg=None):
|
||||
if sys.platform == name:
|
||||
msg(gray('Skipping test {!r} for {} platform{}'.format(
|
||||
self.test_name,
|
||||
name,
|
||||
f' ({extra_msg})' if extra_msg else "")))
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def skip_for_win(self, extra_msg=None):
|
||||
return self.skip_for_platform('win32', extra_msg)
|
||||
|
||||
def spawn_chk(self,*args,**kwargs):
|
||||
"""
|
||||
Drop-in replacement for spawn() + t.read() for tests that spawn more than one process.
|
||||
|
|
|
|||
|
|
@ -1415,7 +1415,7 @@ class CmdTestEthdev(CmdTestBase,CmdTestShared):
|
|||
def edit_comment3(self):
|
||||
return self.edit_comment(out_num=del_addrs[1],comment_text=tw_comment_lat_cyr_gr)
|
||||
def edit_comment4(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no pexpect_spawn'):
|
||||
return 'skip'
|
||||
return self.edit_comment(out_num=del_addrs[0],comment_text=Ctrl_U,pexpect_spawn=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ class CmdTestInput(CmdTestBase):
|
|||
return self._password_entry('Enter passphrase: ',term=term)
|
||||
|
||||
def password_entry_noecho_term(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no pexpect_spawn'):
|
||||
return ('skip_warn','\n' + fmt(self.winskip_msg.format(''),strip_char='\t'))
|
||||
return self.password_entry_noecho(term=True)
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ class CmdTestInput(CmdTestBase):
|
|||
return self._password_entry('Enter passphrase (echoed): ',['--echo-passphrase'],term=term)
|
||||
|
||||
def password_entry_echo_term(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no pexpect_spawn'):
|
||||
return ('skip_warn','\n' + fmt(self.winskip_msg.format(' --echo-passphrase'),strip_char='\t'))
|
||||
return self.password_entry_echo(term=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class CmdTestMisc(CmdTestBase):
|
|||
imsg('[input not echoed - OK]')
|
||||
t.send('x')
|
||||
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no termios support'):
|
||||
return 'skip'
|
||||
|
||||
t = self.spawn('test/misc/term_ni.py',['echo'],cmd_dir='.',pexpect_spawn=True,timeout=1)
|
||||
|
|
@ -148,7 +148,7 @@ class CmdTestMisc(CmdTestBase):
|
|||
return t
|
||||
|
||||
def term_cleanup(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no termios support'):
|
||||
return 'skip'
|
||||
return self.spawn('test/misc/term_ni.py',['cleanup'],cmd_dir='.',pexpect_spawn=True)
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ class CmdTestOutput(CmdTestBase):
|
|||
return t
|
||||
|
||||
def oneshot_warning_term(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no pexpect_spawn'):
|
||||
return 'skip'
|
||||
return self.oneshot_warning(pexpect_spawn=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -1736,7 +1736,7 @@ class CmdTestRegtest(CmdTestBase,CmdTestShared):
|
|||
return t
|
||||
|
||||
def alice_txcreate_info_term(self):
|
||||
if self.skip_for_win():
|
||||
if self.skip_for_win('no pexpect_spawn'):
|
||||
return 'skip'
|
||||
return self.alice_txcreate_info(pexpect_spawn=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue