mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-01 13:45:53 +00:00
test.py: fix test collection bug
In certain circumstances current way of collecting can be error prone. Collection can stop when the first file is skipped in the mode leaving the rest of the files in CLI not collected. Another issue that if the file specified twice, with directory and file explicitly, it will produce incorrect CppFile in the stash causing KeyError. Fixes: https://scylladb.atlassian.net/browse/SCYLLADB-1714
This commit is contained in:
@@ -126,6 +126,9 @@ class CppFile(pytest.File, ABC):
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
def collect(self) -> Iterator[CppTestCase]:
|
def collect(self) -> Iterator[CppTestCase]:
|
||||||
|
if BUILD_MODE not in self.stash:
|
||||||
|
return
|
||||||
|
|
||||||
custom_args = self.suite_config.get("custom_args", {}).get(self.test_name, DEFAULT_CUSTOM_ARGS)
|
custom_args = self.suite_config.get("custom_args", {}).get(self.test_name, DEFAULT_CUSTOM_ARGS)
|
||||||
|
|
||||||
for test_case in self.list_test_cases():
|
for test_case in self.list_test_cases():
|
||||||
|
|||||||
@@ -163,6 +163,11 @@ def scylla_binary(testpy_test) -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
|
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
|
||||||
|
items[:] = [
|
||||||
|
item for item in items
|
||||||
|
if (parent_file := item.getparent(cls=pytest.File)) is not None
|
||||||
|
and BUILD_MODE in parent_file.stash
|
||||||
|
]
|
||||||
for item in items:
|
for item in items:
|
||||||
modify_pytest_item(item=item)
|
modify_pytest_item(item=item)
|
||||||
|
|
||||||
@@ -340,7 +345,8 @@ def pytest_collect_file(file_path: pathlib.Path,
|
|||||||
repeats = list(product(build_modes, parent.config.run_ids))
|
repeats = list(product(build_modes, parent.config.run_ids))
|
||||||
|
|
||||||
if not repeats:
|
if not repeats:
|
||||||
return []
|
parent.stash[REPEATING_FILES].remove(file_path)
|
||||||
|
return collectors
|
||||||
|
|
||||||
ihook = parent.ihook
|
ihook = parent.ihook
|
||||||
collectors = list(chain(collectors, chain.from_iterable(
|
collectors = list(chain(collectors, chain.from_iterable(
|
||||||
|
|||||||
Reference in New Issue
Block a user