blender/tests/python/cycles_osl_compile_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

69 lines
1.6 KiB
Python

# SPDX-FileCopyrightText: 2015-2026 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0
import sys
import tempfile
import unittest
from pathlib import Path
import bpy
import _cycles
args = None
class AbstractOSLCompileTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls._tempdir = tempfile.TemporaryDirectory()
cls.testdir = args.testdir
cls.tempdir = Path(cls._tempdir.name)
def setUp(self):
self.assertTrue(self.testdir.exists(), "Test dir {0} should exist".format(self.testdir))
@classmethod
def tearDownClass(cls):
cls._tempdir.cleanup()
class OSLCompileTest(AbstractOSLCompileTest):
def test_compile_simple(self):
input_file = self.tempdir / "input.osl"
output_file = self.tempdir / "output.oso"
input_file.write_text("""
shader basic_shader(
float in_float = 1.0,
color in_color = color(1.0, 1.0, 1.0),
output float out_float = 0.0,
output color out_color = color(0.0, 0.0, 0.0)
)
{
out_float = in_float * 2.0;
out_color = in_color * 2.0;
}""")
self.assertTrue(_cycles.osl_compile(str(input_file), str(output_file)))
def main():
global args
import argparse
if "--" in sys.argv:
argv = [sys.argv[0]] + sys.argv[sys.argv.index("--") + 1:]
else:
argv = sys.argv
parser = argparse.ArgumentParser()
parser.add_argument("--testdir", required=True, type=Path)
args, remaining = parser.parse_known_args(argv)
unittest.main(argv=remaining, verbosity=0)
if __name__ == "__main__":
main()