blender/tests/python/ui_simulate/run_blender_setup.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

146 lines
4.2 KiB
Python

# SPDX-FileCopyrightText: 2019-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
"""
Utility script, called by ``run.py`` or ``blender_headless.py`` to run inside Blender,
to avoid boilerplate code having to be added into each test.
"""
import os
import sys
def create_parser():
import argparse
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"--keep-open",
dest="keep_open",
default=False,
action='store_true',
required=False,
help="Keep the Blender window open after running the test.",
)
parser.add_argument(
"--step-command-pre",
dest="step_command_pre",
default=None,
required=False,
help="See 'run.py'",
)
parser.add_argument(
"--step-command-post",
dest="step_command_post",
default=None,
required=False,
help="See 'run.py'",
)
parser.add_argument(
"--tests",
dest="tests",
nargs='+',
required=True,
metavar="TEST_ID",
help="Names of tests to run.",
)
return parser
def main():
directory = os.path.dirname(__file__)
sys.path.insert(0, directory)
if "bpy" not in sys.modules:
raise Exception("This must run inside Blender")
import bpy
import gpu
parser = create_parser()
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:])
verbose = os.getenv('BLENDER_VERBOSE') is not None
# Check if `bpy.app.use_event_simulate` has been enabled by the test itself.
# When writing tests, it's useful if the test can temporarily be set to keep the window open.
def on_error():
if not bpy.app.use_event_simulate:
args.keep_open = True
if not args.keep_open:
sys.exit(1)
def on_exit():
if not bpy.app.use_event_simulate:
args.keep_open = True
if not args.keep_open:
try:
bpy.ops.wm.quit_blender()
except RuntimeError:
sys.exit(1)
else:
bpy.app.use_event_simulate = False
gpu_device = gpu.platform.device_type_get()
gpu_backend = gpu.platform.backend_type_get()
BLOCKLIST = []
if os.getenv("BLENDER_TEST_IGNORE_BLOCKLIST") is None and os.getenv("BLENDER_TEST_IGNORE_VENDOR_BLOCKLIST") is None:
if sys.platform == "win32" and gpu_device == "INTEL" and gpu_backend == "OPENGL":
# See #149084 for the tracking issue
BLOCKLIST = ["test_workspace"]
if sys.platform == "linux" and gpu_device == "INTEL" and gpu_backend == "OPENGL":
# See #154228 for the tracking issue
BLOCKLIST = ["view3d_texture_paint_complex"]
if sys.platform == "linux" and gpu_device == "INTEL" and gpu_backend == "VULKAN":
# See #151410 for the tracking issue
BLOCKLIST = ["test_sculpt", "test_tools", "test_undo", "test_workspace"]
if sys.platform == "win32" and gpu_device == "AMD" and gpu_backend == "VULKAN":
# See #151411 for the tracking issue
BLOCKLIST = ["test_sculpt", "test_tools", "test_undo", "test_workspace"]
is_first = True
for test_id in args.tests:
mod_name, fn_name = test_id.partition(".")[0::2]
if mod_name in BLOCKLIST or test_id in BLOCKLIST:
if not args.keep_open:
try:
bpy.ops.wm.quit_blender()
except RuntimeError:
sys.exit(1)
if not is_first:
bpy.ops.wm.read_homefile()
is_first = False
mod = __import__(mod_name)
test_fn = getattr(mod, fn_name)
from modules import easy_keys
# So we can get the operator ID's.
bpy.context.preferences.view.show_developer_ui = True
# Hack back in operator search.
easy_keys.setup_default_preferences(bpy.context.preferences)
easy_keys.run(
test_fn(),
on_error=on_error,
on_exit=on_exit,
# Optional.
on_step_command_pre=args.step_command_pre,
on_step_command_post=args.step_command_post,
)
if __name__ == "__main__":
main()