This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nuttx-ntfc.git
The following commit(s) were added to refs/heads/main by this push:
new 9e17dbe collector: add exclude_test to session.json
9e17dbe is described below
commit 9e17dbeacd02c9081dd0512dac5e6a3cf4730167
Author: raiden00pl <[email protected]>
AuthorDate: Sat Oct 10 11:51:00 2026 +0200
collector: add exclude_test to session.json
Lets a board config skip a single test by its pytest item name,
without blacklisting it in the test suite for every board.
Signed-off-by: raiden00pl <[email protected]>
---
Documentation/session-json.rst | 10 ++++++++++
src/ntfc/pytest/collector.py | 24 ++++++++++++++++++++----
tests/pytest/test_collector.py | 21 +++++++++++++++++++++
3 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/Documentation/session-json.rst b/Documentation/session-json.rst
index 176d02d..9e11461 100644
--- a/Documentation/session-json.rst
+++ b/Documentation/session-json.rst
@@ -19,6 +19,9 @@ and argument overrides. Path to test session configuration
file is passed with
"exclude_module": [
"Nuttx_System_Arch_Os_Performance"
],
+ "exclude_test": [
+ "test_ltp_integration[ltp_interfaces_pthread_rwlock_unlock_4_2]"
+ ],
"order": []
},
"args": {
@@ -36,6 +39,13 @@ and argument overrides. Path to test session configuration
file is passed with
- ``exclude_module``: Modules to exclude
+- ``exclude_test``: Individual tests to exclude, by pytest item name. For a
+ parametrized test the name includes the parameter, e.g.
+ ``test_ltp_integration[ltp_interfaces_pthread_rwlock_unlock_4_2]``. A name
+ matches in every module, so a board can blacklist a single case that is
+ known to fail on it without touching the test suite. An excluded test is
+ dropped from the session the same way as the tests of an excluded module.
+
- ``order``: Force execution order. Specifies a list of objects with ``module``
and ``value``.
diff --git a/src/ntfc/pytest/collector.py b/src/ntfc/pytest/collector.py
index 9feca19..c451e25 100644
--- a/src/ntfc/pytest/collector.py
+++ b/src/ntfc/pytest/collector.py
@@ -21,7 +21,7 @@
"""NTFC collector plugin for pytest."""
import os
-from typing import TYPE_CHECKING, Dict, List, Tuple
+from typing import TYPE_CHECKING, Dict, List, Optional, Tuple
import pytest
@@ -130,15 +130,30 @@ class CollectorPlugin:
"""Pytest collection finish callback."""
def _filter_modules(
- self, ci: CollectedItem, include: List[str], exclude: List[str]
+ self,
+ ci: CollectedItem,
+ include: List[str],
+ exclude: List[str],
+ exclude_test: Optional[List[str]] = None,
) -> Tuple[bool, str]:
- """Filter modules based on include/exclude lists."""
+ """Filter modules based on include/exclude lists.
+
+ :param ci: Collected item to check.
+ :param include: Modules to run; everything else is skipped.
+ :param exclude: Modules to skip.
+ :param exclude_test: Test names to skip, e.g.
+ ``test_ltp_integration[ltp_interfaces_pthread_rwlock_unlock_4_2]``.
+ :return: ``(skip, reason)`` tuple.
+ """
if include and ci.module2 not in include:
return True, "not in include_module"
if exclude and ci.module2 in exclude:
return True, "excluded module"
+ if exclude_test and ci.name in exclude_test:
+ return True, "excluded test"
+
return False, ""
def _order_items(
@@ -172,6 +187,7 @@ class CollectorPlugin:
module = pytest.cfgtest.get("module", {})
include_module = module.get("include_module", [])
exclude_module = module.get("exclude_module", [])
+ exclude_test = module.get("exclude_test", [])
order_list = module.get("order", [])
order_map = {
e["module"]: int(e["value"])
@@ -187,7 +203,7 @@ class CollectorPlugin:
skip, reason = self._filter.check_test_support(item)
if not skip:
skip, reason = self._filter_modules(
- ci, include_module, exclude_module
+ ci, include_module, exclude_module, exclude_test
)
if skip:
diff --git a/tests/pytest/test_collector.py b/tests/pytest/test_collector.py
index 2758d92..402a20c 100644
--- a/tests/pytest/test_collector.py
+++ b/tests/pytest/test_collector.py
@@ -83,6 +83,27 @@ def test_runner_module_exclude(config_sim, device_dummy):
assert item.module2 != "test_Test1"
+def test_runner_test_exclude(config_sim, device_dummy):
+ with patch("ntfc.cores.get_device", return_value=device_dummy):
+ jsoncfg = {
+ "module": {
+ "exclude_test": ["test_test2_simple_1"],
+ }
+ }
+
+ p = MyPytest(config_sim, confjson=jsoncfg)
+ path = "./tests/resources/tests_dirs"
+ col = p.collect(path)
+
+ # 8 total - 1 excluded by name = 7 items
+ assert len(col.items) == 7
+ for item in col.items:
+ assert item.name != "test_test2_simple_1"
+
+ skipped = {item.name: reason for item, reason in col.skipped}
+ assert skipped == {"test_test2_simple_1": "excluded test"}
+
+
def test_runner_module_order_complex(config_sim, device_dummy):
with patch("ntfc.cores.get_device", return_value=device_dummy):
# Multiple positive and negative values