From 886f21cb2e24587a9363ce69565545da5c9ff655 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Wed, 9 Feb 2022 16:51:01 +0100 Subject: [PATCH] Add option to select test cases by markers Change-Id: I773b710eb4f4a8abb1cebc13088d3cc16ff08334 --- infrared_plugin/plugin.spec | 6 ++++++ roles/tobiko-tox/defaults/main.yaml | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/infrared_plugin/plugin.spec b/infrared_plugin/plugin.spec index 7fcf58c59..cb7bc2a6c 100644 --- a/infrared_plugin/plugin.spec +++ b/infrared_plugin/plugin.spec @@ -191,6 +191,12 @@ subparsers: type: Value help: Extra options to be passed to PyTest ansible_variable: pytest_addopts + pytest-markers: + type: Value + help: > + only run tests matching given mark expression. + For example: --pytest-markers 'mark1 and not mark2'. + ansible_variable: pytest_markers pytest-maxfail: type: Value help: Max number of test case failures before aborting diff --git a/roles/tobiko-tox/defaults/main.yaml b/roles/tobiko-tox/defaults/main.yaml index a77ec9b57..b04a5d427 100644 --- a/roles/tobiko-tox/defaults/main.yaml +++ b/roles/tobiko-tox/defaults/main.yaml @@ -21,7 +21,7 @@ tox_constraints: '' tox_constrain_env: PYTEST_ADDOPTS: > - {% if not test_flaky%}-m 'not flaky'{% endif %} + {% if pytest_markers %}-m '{{ pytest_markers }}'{% endif %} {% if pytest_maxfail %}--maxfail '{{ pytest_maxfail }}'{% endif %} {{ pytest_addopts }} TOX_REPORT_DIR: '{{ tox_report_dir }}' @@ -37,5 +37,6 @@ tox_expected_rcs: ignore_test_failures: no pytest_addopts: '' +pytest_markers: "{% if not test_flaky%}not flaky{% endif %}" pytest_maxfail: '' test_flaky: false