blender/tests/performance/api/test.py
Testfiya a1de44dd54 iOS: Bump version to 5.1.2
This commit bumps the `ios` branch from 5.0.0 alpha to 5.1.2 release.

I merged v5.0-release first then v5.1-release. So it was a sequential
merge.

I'm just waiting to the approval of continuing development.

The stuff that are missing (those are so close to implement):
- #145484 iOS: Keyboard Input Support: https://projects.blender.org/blender/blender/pulls/145484
- #145702 iOS: Add clipboard Image: https://projects.blender.org/blender/blender/pulls/145702
- Fix QOS threading
- Expose Downloads
- UIScene Migration

`make deps` needs to run two times. (still hacky....) OSL occurs racing
conditions.

Disclaimer: I used AI for searching in Documentation of Deps. So the
implementation is by hand. **SACRED PINKY FINGER PROMISE**

Pull Request: https://projects.blender.org/blender/blender/pulls/161073
2026-07-07 16:03:12 +02:00

94 lines
2.6 KiB
Python

# SPDX-FileCopyrightText: 2021-2022 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0
import abc
import fnmatch
class Test:
@abc.abstractmethod
def name(self) -> str:
"""
Name of the test.
"""
@abc.abstractmethod
def category(self) -> str:
"""
Category of the test.
"""
def use_device(self) -> bool:
"""
Test uses a specific CPU or GPU device.
"""
return False
def use_background(self) -> bool:
"""
Test runs in background mode and requires no display.
"""
return True
@abc.abstractmethod
def run(self, env, device_id: str) -> dict:
"""
Execute the test and report results.
"""
class TestCollection:
def __init__(self, env, names_filter: list = ['*'], categories_filter: list = ['*'], background: bool = False):
import importlib
import pkgutil
import tests
self.tests = []
# Find and import all Python files in the tests folder, and generate
# the list of tests for each.
for _, modname, _ in pkgutil.iter_modules(tests.__path__, 'tests.'):
module = importlib.import_module(modname)
tests = module.generate(env)
for test in tests:
if background and not test.use_background():
continue
test_category = test.category()
found = False
for category_filter in categories_filter:
if fnmatch.fnmatch(test_category, category_filter):
found = True
if not found:
continue
test_name = test.name()
included = False
excluded = False
for name_filter in names_filter:
is_exclusion = name_filter.startswith('!')
pattern = name_filter[1:] if is_exclusion else name_filter
if fnmatch.fnmatch(test_name, pattern):
if is_exclusion:
excluded = True
break
else:
included = True
if not included or excluded:
continue
self.tests.append(test)
def find(self, test_name: str, test_category: str):
# Find a test based on name and category.
for test in self.tests:
if test.name() == test_name and test.category() == test_category:
return test
return None