scripts: twister: harness: pytest: add support for custom cmd line args
Add support for passing custom command line arguments to a pytest harness in twister. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
db12728efc
commit
7249dab0c8
3 changed files with 19 additions and 1 deletions
|
@ -369,11 +369,14 @@ harness_config: <harness configuration options>
|
|||
|
||||
Only one fixture can be defined per testcase.
|
||||
|
||||
pytest_root: <pytest dirctory> (default pytest)
|
||||
pytest_root: <pytest directory> (default pytest)
|
||||
Specify a pytest directory which need to excute when test case begin to running,
|
||||
default pytest directory name is pytest, after pytest finished, twister will
|
||||
check if this case pass or fail according the pytest report.
|
||||
|
||||
pytest_args: <list of arguments> (default empty)
|
||||
Specify a list of additional arguments to pass to ``pytest``.
|
||||
|
||||
The following is an example yaml file with a few harness_config options.
|
||||
|
||||
::
|
||||
|
|
|
@ -131,11 +131,13 @@ class Pytest(Harness):
|
|||
self.running_dir = instance.build_dir
|
||||
self.source_dir = instance.testcase.source_dir
|
||||
self.pytest_root = 'pytest'
|
||||
self.pytest_args = []
|
||||
self.is_pytest = True
|
||||
config = instance.testcase.harness_config
|
||||
|
||||
if config:
|
||||
self.pytest_root = config.get('pytest_root', 'pytest')
|
||||
self.pytest_args = config.get('pytest_args', [])
|
||||
|
||||
def handle(self, line):
|
||||
''' Test cases that make use of pytest more care about results given
|
||||
|
@ -164,6 +166,9 @@ class Pytest(Harness):
|
|||
'-q'
|
||||
]
|
||||
|
||||
for arg in self.pytest_args:
|
||||
cmd.append(arg)
|
||||
|
||||
log = open(log_file, "a")
|
||||
outs = []
|
||||
errs = []
|
||||
|
|
|
@ -65,6 +65,11 @@ mapping:
|
|||
"pytest_root":
|
||||
type: str
|
||||
required: false
|
||||
"pytest_args":
|
||||
type: seq
|
||||
required: false
|
||||
sequence:
|
||||
- type: str
|
||||
"regex":
|
||||
type: seq
|
||||
required: false
|
||||
|
@ -193,6 +198,11 @@ mapping:
|
|||
"pytest_root":
|
||||
type: str
|
||||
required: false
|
||||
"pytest_args":
|
||||
type: seq
|
||||
required: false
|
||||
sequence:
|
||||
- type: str
|
||||
"regex":
|
||||
type: seq
|
||||
required: false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue