mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Merge branch 'blender-v5.1-release'
This commit is contained in:
commit
8e9f124de3
2 changed files with 77 additions and 0 deletions
|
|
@ -943,6 +943,15 @@ if((WITH_CYCLES OR WITH_GPU_RENDER_TESTS) AND TEST_SRC_DIR_EXISTS)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_CYCLES AND WITH_CYCLES_OSL)
|
||||
add_blender_test(
|
||||
cycles_osl_compile_test
|
||||
--python ${CMAKE_CURRENT_LIST_DIR}/cycles_osl_compile_test.py
|
||||
--
|
||||
--testdir "${TEST_SRC_DIR}/render"
|
||||
)
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# COMPOSITOR TESTS
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
|||
68
tests/python/cycles_osl_compile_test.py
Normal file
68
tests/python/cycles_osl_compile_test.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# 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))
|
||||
|
||||
def tearDown(self):
|
||||
self._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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue