From 780c6ad024dae44ae9f3c19c35c1da2d538e484e Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Tue, 7 Oct 2025 05:46:34 +0200 Subject: [PATCH] Tests: Alembic: Add coverage for point cloud attribute import validation Adds coverage for recently added import of pointcloud attributes. See PR blender/blender!145946 Pull Request: https://projects.blender.org/blender/blender/pulls/147494 --- .../alembic/compare/point_attributes.abc | 3 ++ .../compare/reference/point_attributes.txt | 39 +++++++++++++++++++ tests/python/CMakeLists.txt | 1 + tests/python/bl_alembic_io_test.py | 37 ++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 tests/files/alembic/compare/point_attributes.abc create mode 100644 tests/files/alembic/compare/reference/point_attributes.txt diff --git a/tests/files/alembic/compare/point_attributes.abc b/tests/files/alembic/compare/point_attributes.abc new file mode 100644 index 00000000000..f82d20c76fd --- /dev/null +++ b/tests/files/alembic/compare/point_attributes.abc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f1f36490115b08dce26389f2d578b0151ed60e167f602e53bd2758d1aa5b740 +size 2490 diff --git a/tests/files/alembic/compare/reference/point_attributes.txt b/tests/files/alembic/compare/reference/point_attributes.txt new file mode 100644 index 00000000000..94140b04e47 --- /dev/null +++ b/tests/files/alembic/compare/reference/point_attributes.txt @@ -0,0 +1,39 @@ +==== Point Clouds: 1 +- PointCloud 'particles' points:5 + - attr 'emission' FLOAT_COLOR POINT + - (3.261, 0.846, 0.097, 1.000) + - (3.188, 0.827, 0.094, 1.000) + - (3.660, 0.949, 0.108, 1.000) + - (3.597, 0.933, 0.107, 1.000) + - (3.205, 0.831, 0.095, 1.000) + - attr 'normals' FLOAT_VECTOR POINT + - (-0.467, 0.698, 0.544) + - (-0.708, 0.276, -0.650) + - (0.652, -0.041, -0.757) + - (0.672, -0.274, 0.688) + - (-0.705, -0.664, 0.249) + - attr 'position' FLOAT_VECTOR POINT + - (-2.168, 0.698, -0.916) + - (1.324, 0.276, -2.865) + - (3.020, -0.041, 1.284) + - (-1.478, -0.274, 2.791) + - (-1.483, -0.664, -1.957) + - attr 'radius' FLOAT POINT + - 0.577 0.577 0.577 0.577 0.577 + - attr 'temperature' FLOAT POINT + - 0.400 0.400 0.400 0.400 0.400 + - attr 'uv' FLOAT2 POINT + - (0.863, 0.746) + - (0.118, 0.589) + - (0.363, 0.487) + - (0.627, 0.412) + - (0.946, 0.269) + +==== Objects: 1 +- Obj 'particles' POINTCLOUD data:'particles' + - pos 0.000, 0.000, 0.000 + - rot 0.000, 0.000, 0.000 (XYZ) + - scl 1.000, 1.000, 1.000 + - 1 modifiers + - MESH_SEQUENCE_CACHE 'MeshSequenceCache' + diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 2642195a321..9dabaccff6b 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -1177,6 +1177,7 @@ if(WITH_ALEMBIC AND TEST_SRC_DIR_EXISTS) --python ${CMAKE_CURRENT_LIST_DIR}/bl_alembic_io_test.py -- --testdir "${TEST_SRC_DIR}/alembic" + --outdir "${TEST_OUT_DIR}/io_alembic" ) endif() diff --git a/tests/python/bl_alembic_io_test.py b/tests/python/bl_alembic_io_test.py index 5fcd9b13608..4d5e3fdd305 100644 --- a/tests/python/bl_alembic_io_test.py +++ b/tests/python/bl_alembic_io_test.py @@ -14,6 +14,8 @@ import unittest import bpy +sys.path.append(str(pathlib.Path(__file__).parent.absolute())) + args = None @@ -449,6 +451,40 @@ class OverrideLayersTest(AbstractAlembicTest): self.assertEqual(len(mesh.polygons), 6) +class AlembicImportComparisonTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.testdir = args.testdir + cls.output_dir = args.outdir + + def test_import_alembic(self): + comparisondir = self.testdir.joinpath("compare") + input_files = sorted(pathlib.Path(comparisondir).glob("*.abc")) + self.passed_tests = [] + self.failed_tests = [] + self.updated_tests = [] + + from modules import io_report + report = io_report.Report("Alembic Import", self.output_dir, comparisondir, comparisondir.joinpath("reference")) + io_report.Report.context_lines = 8 + + for input_file in input_files: + input_file_path = pathlib.Path(input_file) + + io_report.Report.side_to_print_single_line = 5 + io_report.Report.side_to_print_multi_line = 3 + + with self.subTest(input_file_path.stem): + bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "empty.blend")) + ok = report.import_and_check( + input_file, lambda filepath, params: bpy.ops.wm.alembic_import( + filepath=str(input_file), **params)) + if not ok: + self.fail(f"{input_file.stem} import result does not match expectations") + + report.finish("io_alembic_import") + + def main(): global args import argparse @@ -460,6 +496,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('--testdir', required=True, type=pathlib.Path) + parser.add_argument('--outdir', required=True, type=pathlib.Path) args, remaining = parser.parse_known_args(argv) unittest.main(argv=remaining)