File: CMakeLists.txt

package info (click to toggle)
blender 5.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 329,128 kB
  • sloc: cpp: 2,489,823; python: 349,859; ansic: 261,364; xml: 2,103; sh: 999; javascript: 317; makefile: 193
file content (1475 lines) | stat: -rw-r--r-- 41,841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
# SPDX-FileCopyrightText: 2011-2023 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later

# Use '--write-blend=/tmp/test.blend' to view output

set(TEST_SRC_DIR ${CMAKE_SOURCE_DIR}/tests/files)
set(TEST_PYTHON_DIR ${CMAKE_SOURCE_DIR}/tests/python)
set(TEST_OUT_DIR ${CMAKE_BINARY_DIR}/tests)

# ugh, any better way to do this on testing only?
file(MAKE_DIRECTORY ${TEST_OUT_DIR})
file(MAKE_DIRECTORY ${TEST_OUT_DIR}/io_tests)
file(MAKE_DIRECTORY ${TEST_OUT_DIR}/blendfile_io)

# Check which tests can be enabled.
if(IS_DIRECTORY ${TEST_SRC_DIR}/render)
  set(TEST_SRC_DIR_EXISTS TRUE)

  if(OPENIMAGEIO_TOOL)
    set(TEST_OPENIMAGEIO_TOOL_EXISTS TRUE)
  else()
    set(TEST_OPENIMAGEIO_TOOL_EXISTS FALSE)
    message(STATUS "Tests: Disabling render tests, missing oiiotool")
  endif()
else()
  set(TEST_SRC_DIR_EXISTS FALSE)
  message(STATUS "Tests: Disabling most tests, no test data in ${TEST_SRC_DIR}")
endif()

if(WITH_SYSTEM_PYTHON_TESTS)
  if(NOT EXISTS "${TEST_SYSTEM_PYTHON_EXE}")
    message(ERROR
      "'System Python' tests requested but no valid system python path, "
      "set TEST_SYSTEM_PYTHON_EXE."
    )
    set(WITH_SYSTEM_PYTHON_TESTS OFF)
  endif()
endif()

# Run Blender command with parameters.
function(add_blender_test_impl testname envvars_list exe)
  add_test(
    NAME ${testname}
    COMMAND ${exe} ${ARGN}
  )
  blender_test_set_envvars("${testname}" "${envvars_list}")
endfunction()

function(add_blender_test testname)
  add_blender_test_impl(
    "${testname}"
    ""
    "${TEST_BLENDER_EXE}"
    ${TEST_BLENDER_EXE_PARAMS}
    ${ARGN}
  )
endfunction()

function(add_blender_test_allow_error testname)
  # Remove `--debug-exit-on-error` since errors are printed on e.g. meshes with
  # invalid data or failed image loading, but sometimes we want to test those.
  set(EXE_PARAMS ${TEST_BLENDER_EXE_PARAMS})
  list(REMOVE_ITEM EXE_PARAMS --debug-exit-on-error)
  add_blender_test_impl(
    "${testname}"
    ""
    "${TEST_BLENDER_EXE}"
    ${EXE_PARAMS}
    ${ARGN}
  )
endfunction()

if(WITH_UI_TESTS)
  set(_blender_headless_env_vars "BLENDER_BIN=${TEST_BLENDER_EXE}")
  if(WITH_UI_TESTS_HEADLESS)

    # Currently only WAYLAND is supported, support for others may be added later.
    # In this case none of the WESTON environment variables will be used.
    if(WITH_GHOST_WAYLAND)
      set(_weston_bin_in_libdir OFF)
      if(DEFINED LIBDIR)
        set(_weston_bin_default "${LIBDIR}/wayland_weston/bin/weston")
      else()
        set(_weston_bin_default "weston")
      endif()
      set(WESTON_BIN "${_weston_bin_default}" CACHE STRING "\
  The location of weston, leave blank for the default location."
      )
      mark_as_advanced(WESTON_BIN)
      if((DEFINED LIBDIR) AND ("${WESTON_BIN}" STREQUAL "${_weston_bin_default}"))
        set(_weston_bin_in_libdir ON)
      endif()

      list(APPEND _blender_headless_env_vars
        "WESTON_BIN=${WESTON_BIN}"
      )

      if(_weston_bin_in_libdir)
        list(APPEND _blender_headless_env_vars
          "WAYLAND_ROOT_DIR=${LIBDIR}/wayland"
          "WESTON_ROOT_DIR=${LIBDIR}/wayland_weston"
        )
      endif()
    endif()
  else()
    list(APPEND _blender_headless_env_vars
      "PASS_THROUGH=1"
    )
  endif()
  function(add_blender_test_ui testname)
    # Remove `--background`a
    set(EXE_PARAMS ${TEST_BLENDER_EXE_PARAMS})
    list(REMOVE_ITEM EXE_PARAMS --background)
    add_blender_test_impl(
      "${testname}"
      "${_blender_headless_env_vars}"
      "${TEST_PYTHON_EXE}"
      "${CMAKE_SOURCE_DIR}/tests/utils/blender_headless.py"
      # NOTE: attempting to maximize the window causes problems with a headless `weston`,
      # while this could be investigated, use windowed mode instead.
      # Use a window size that balances software GPU rendering with enough room to use the UI.
      --factory-startup
      # Used so GHOST/Wayland doesn't attempt to load LIBDECOR
      # which can fail on some systems, causing tests to fail.
      # On other systems this is harmless.
      --no-window-frame
      -p 0 0 800 600
      "${EXE_PARAMS}"
      "${ARGN}"
    )
  endfunction()
endif()

# Run Python script outside Blender.
function(add_python_test testname testscript)
  if(NOT TEST_PYTHON_EXE)
    message(FATAL_ERROR "No Python configured for running tests, set TEST_PYTHON_EXE.")
  endif()

  add_test(
    NAME ${testname}
    COMMAND ${TEST_PYTHON_EXE} ${TEST_PYTHON_EXE_EXTRA_ARGS} ${testscript} ${ARGN}
    WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>
  )
  blender_test_set_envvars("${testname}" "")
endfunction()

# Run Python render test.
function(add_render_test testname testscript)
  if(TEST_OPENIMAGEIO_TOOL_EXISTS)
    set(_args ${ARGN} --blender "${TEST_BLENDER_EXE}" --oiiotool "${OPENIMAGEIO_TOOL}")
    if(WITH_TESTS_BATCHED)
      list(APPEND _args --batch)
    endif()
    add_python_test(${testname} ${testscript} ${_args})
  endif()
endfunction()

# Run Python script outside Blender, using system default Python3 interpreter,
# NOT the one specified in `TEST_PYTHON_EXE`.
function(add_system_python_test testname testscript)
  if(NOT WITH_SYSTEM_PYTHON_TESTS)
    return()
  endif()

  add_test(
    NAME ${testname}
    COMMAND ${TEST_SYSTEM_PYTHON_EXE} ${testscript} ${ARGN}
    WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>
  )
  blender_test_set_envvars("${testname}" "")
endfunction()

# ------------------------------------------------------------------------------
# TESTS USING SYSTEM PYTHON
# ------------------------------------------------------------------------------

add_system_python_test(
  script_validate_on_system_python
  ${CMAKE_CURRENT_LIST_DIR}/system_python/load_tool_scripts.py
  --root-dir ${CMAKE_SOURCE_DIR}
)

# ------------------------------------------------------------------------------
# GENERAL PYTHON CORRECTNESS TESTS
# ------------------------------------------------------------------------------

add_blender_test(
  script_load_keymap
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_keymap_completeness.py
)

add_blender_test(
  script_validate_keymap
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_keymap_validate.py
  -- --relaxed  # Disable minor things that should not cause tests to break.
)

add_blender_test(
  script_load_addons
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_load_addons.py
)

add_blender_test(
  script_load_modules
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_load_py_modules.py
)

add_blender_test(
  script_bundled_modules
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_bundled_modules.py -- --inside-blender
)

add_blender_test(
  script_http_downloader
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_http_downloader.py
)

# test running operators doesn't segfault under various conditions
if(WITH_TESTS_EXPERIMENTAL)
  add_blender_test(
    script_run_operators
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_run_operators.py
  )
endif()

# ------------------------------------------------------------------------------
# PY API TESTS
# ------------------------------------------------------------------------------

add_blender_test(
  script_pyapi_bpy_app_tempdir
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_app_tempdir.py
)

add_blender_test(
  script_pyapi_bpy_path
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_path.py
)

add_blender_test(
  script_pyapi_bpy_utils_units
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_utils_units.py
)

add_blender_test(
  script_pyapi_mathutils
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_mathutils.py
)

add_blender_test(
  script_pyapi_bpy_driver_secure_eval
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bpy_driver_secure_eval.py
)

add_blender_test(
  script_pyapi_idprop
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_idprop.py
)

add_blender_test(
  script_pyapi_idprop_datablock
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_idprop_datablock.py
)

add_blender_test(
  script_pyapi_prop
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_prop.py
)

add_blender_test(
  script_pyapi_prop_array
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_prop_array.py
)

add_blender_test(
  script_pyapi_text
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_text.py
)

add_blender_test(
  script_pyapi_bmesh
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_bmesh.py
)

add_blender_test(
  script_pyapi_grease_pencil
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_pyapi_grease_pencil.py
)

# ------------------------------------------------------------------------------
# DATA MANAGEMENT TESTS
# ------------------------------------------------------------------------------

add_blender_test(
  id_management
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_id_management.py
)

add_blender_test(
  bl_rna_paths
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_rna_paths.py
)

add_blender_test(
  bl_rna_accessors
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_rna_accessors.py
)

# ------------------------------------------------------------------------------
# BLEND IO & LINKING
# ------------------------------------------------------------------------------

add_blender_test(
  blendfile_io
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_io.py --
  --output-dir ${TEST_OUT_DIR}/blendfile_io/
)

# This test can be extremely long, especially in debug builds.
# Generate BLENDFILE_VERSIONING_SPLIT_RANGE instances of the test,
# each processing their own subset of the whole set of blendfiles.
if(TEST_SRC_DIR_EXISTS)
  set(BLENDFILE_VERSIONING_SPLIT_RANGE 128)
  math(EXPR BLENDFILE_VERSIONING_SPLIT_RANGE_CMAKE "${BLENDFILE_VERSIONING_SPLIT_RANGE} - 1")
  foreach(idx RANGE ${BLENDFILE_VERSIONING_SPLIT_RANGE_CMAKE})
    add_blender_test(
      "blendfile_versioning_${idx}_over_${BLENDFILE_VERSIONING_SPLIT_RANGE}"
      --log "*blendfile*"
      --debug-memory
      --debug
      --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_versioning.py --
      --src-test-dir ${TEST_SRC_DIR}/
      --output-dir ${TEST_OUT_DIR}/blendfile_io/
      --slice-range ${BLENDFILE_VERSIONING_SPLIT_RANGE}
      --slice-index ${idx}
    )
  endforeach()

  add_blender_test(
    blendfile_liblink
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_liblink.py --
    --src-test-dir ${TEST_SRC_DIR}/
    --output-dir ${TEST_OUT_DIR}/blendfile_io/
  )

  add_blender_test(
    blendfile_relationships
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_relationships.py --
    --src-test-dir ${TEST_SRC_DIR}/
    --output-dir ${TEST_OUT_DIR}/blendfile_io/
  )

  add_blender_test(
    blendfile_library_overrides
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_library_overrides.py --
    --output-dir ${TEST_OUT_DIR}/blendfile_io/
    --test-dir "${TEST_SRC_DIR}/libraries_and_linking"
  )

  add_blender_test(
    blendfile_header
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_header.py --
    --testdir "${TEST_SRC_DIR}/io_tests/blend_parsing"
  )
endif()

# ------------------------------------------------------------------------------
# MODELING TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    bmesh_bevel
    ${TEST_SRC_DIR}/modeling/bevel_regression.blend
    --python ${TEST_PYTHON_DIR}/bevel_operator.py
    --
    --run-all-tests
  )

  add_blender_test(
    bmesh_boolean
    ${TEST_SRC_DIR}/modeling/bool_regression.blend
    --python ${TEST_PYTHON_DIR}/boolean_operator.py
    --
    --run-all-tests
  )

  add_blender_test(
    bmesh_split_faces
    ${TEST_SRC_DIR}/modeling/split_faces_test.blend
    --python-text run_tests
  )

  add_blender_test(
    curve_to_mesh
    ${TEST_SRC_DIR}/modeling/curve_to_mesh.blend
    --python ${TEST_PYTHON_DIR}/curve_to_mesh.py
    --
    --run-all-tests
  )

  add_blender_test(
    curves_extrude
    ${TEST_SRC_DIR}/modeling/curves_extrude.blend
    --python ${TEST_PYTHON_DIR}/curves_extrude.py
    --
    --run-all-tests
  )

  add_blender_test(
    mesh_join
    --python ${TEST_PYTHON_DIR}/mesh_join.py
  )

  add_blender_test(
    object_edit
    --python ${TEST_PYTHON_DIR}/object_edit.py
  )

  add_blender_test(
    object_conversion
    ${TEST_SRC_DIR}/modeling/object_conversion.blend
    --python ${TEST_PYTHON_DIR}/object_conversion.py
    --
    --run-all-tests
  )

  add_blender_test(
    object_api
    --python ${TEST_PYTHON_DIR}/bl_object.py
  )
endif()

add_blender_test(
  geometry_attributes
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_geometry_attributes.py
)

add_blender_test(
  geonode_file_reporting
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_geonode_file_reporting.py
  --
  --testdir "${TEST_SRC_DIR}/io_tests"
)

# ------------------------------------------------------------------------------
# MODIFIERS TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    object_modifier_array
    ${TEST_SRC_DIR}/modifier_stack/array_test.blend
    --python-text run_tests.py
  )

  add_blender_test(
    modifiers
    ${TEST_SRC_DIR}/modeling/modifiers.blend
    --python ${TEST_PYTHON_DIR}/modifiers.py
    --
    --run-all-tests
  )

  add_blender_test(
    physics_cloth
    ${TEST_SRC_DIR}/physics/cloth_test.blend
    --python ${TEST_PYTHON_DIR}/physics_cloth.py
    --
    --run-all-tests
  )

  add_blender_test(
    physics_softbody
    ${TEST_SRC_DIR}/physics/softbody_test.blend
    --python ${TEST_PYTHON_DIR}/physics_softbody.py
    --
    --run-all-tests
  )

  add_blender_test(
    physics_dynamic_paint
    ${TEST_SRC_DIR}/physics/dynamic_paint_test.blend
    --python ${TEST_PYTHON_DIR}/physics_dynamic_paint.py
    --
    --run-all-tests
  )

  add_blender_test(
    deform_modifiers
    ${TEST_SRC_DIR}/modeling/deform_modifiers.blend
    --python ${TEST_PYTHON_DIR}/deform_modifiers.py
    --
    --run-all-tests
  )

  if(WITH_MOD_OCEANSIM)
    add_blender_test(
      physics_ocean
      ${TEST_SRC_DIR}/physics/ocean_test.blend
      --python ${TEST_PYTHON_DIR}/physics_ocean.py
      --
      --run-all-tests
    )
  endif()

  add_blender_test(
    physics_particle_system
    ${TEST_SRC_DIR}/physics/physics_particle_test.blend
    --python ${TEST_PYTHON_DIR}/physics_particle_system.py
    --
    --run-all-tests
  )

  add_blender_test(
    physics_particle_instance
    ${TEST_SRC_DIR}/physics/physics_particle_instance.blend
    --python ${TEST_PYTHON_DIR}/physics_particle_instance.py
    --
    --run-all-tests
  )

  add_blender_test(
    constraints
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_constraints.py
    --
    --testdir "${TEST_SRC_DIR}/constraints"
  )

  add_blender_test(
    multires
    --python ${TEST_PYTHON_DIR}/bl_multires.py
    --
    --testdir "${TEST_SRC_DIR}/sculpting"
  )
endif()

# ------------------------------------------------------------------------------
# OPERATORS TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    operators
    ${TEST_SRC_DIR}/modeling/operators.blend
    --python ${TEST_PYTHON_DIR}/operators.py
    --
    --run-all-tests
  )
endif()

# ------------------------------------------------------------------------------
# ANIMATION TESTS
# ------------------------------------------------------------------------------

add_blender_test(
  bl_animation_armature
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_armature.py
)

add_blender_test(
  bl_animation_bake
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_bake.py
)

add_blender_test(
  bl_animation_nla_strip
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_nla_strip.py
)

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    bl_animation_drivers
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_drivers.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )

  add_blender_test(
    bl_animation_fcurves
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_fcurves.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )

  add_blender_test(
    bl_animation_action
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_action.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
    --output-dir "${TEST_OUT_DIR}/bl_animation_action"
  )

  add_blender_test(
    bl_animation_keyframing
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_animation_keyframing.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )

  add_blender_test(
    bl_pose_assets
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_pose_assets.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )

  add_blender_test(
    bl_rigging_symmetrize
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_rigging_symmetrize.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )

  add_blender_test(
    vertex_group_painting
    --python ${CMAKE_CURRENT_LIST_DIR}/vertex_group_painting.py
    --
    --testdir "${TEST_SRC_DIR}/animation"
  )
endif()

# ------------------------------------------------------------------------------
# BRUSH TESTS
add_blender_test(
  bl_brush
  --python ${CMAKE_CURRENT_LIST_DIR}/bl_brush_test.py
)

# ------------------------------------------------------------------------------
# NODE GROUP TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    bl_node_structure_type_inference
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_node_structure_type_inference.py
    --
    --testdir "${TEST_SRC_DIR}/node_group"
  )

  add_blender_test(
    bl_node_socket_usage_inference
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_node_socket_usage_inference.py
    --
    --testdir "${TEST_SRC_DIR}/node_group"
  )

  add_blender_test(
    bl_node_group_compat
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_node_group_compat.py
    --
    --testdir "${TEST_SRC_DIR}/node_group"
  )

  add_blender_test(
    bl_node_group_interface
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_node_group_interface.py
    --
    --testdir "${TEST_SRC_DIR}/node_group"
  )
endif()

# ------------------------------------------------------------------------------
# SVG TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  set(_svg_render_tests complex path)

  foreach(render_test ${_svg_render_tests})
    add_render_test(
      io_curve_svg_${render_test}
      ${CMAKE_CURRENT_LIST_DIR}/bl_io_curve_svg_test.py
      --testdir "${TEST_SRC_DIR}/io_tests/svg/${render_test}"
      --outdir "${TEST_OUT_DIR}/io_curve_svg"
    )
  endforeach()

  unset(_svg_render_tests)
endif()

# ------------------------------------------------------------------------------
# RENDER TESTS
# ------------------------------------------------------------------------------

if((WITH_CYCLES OR WITH_GPU_RENDER_TESTS) AND TEST_SRC_DIR_EXISTS)
  set(render_tests
    attributes
    camera
    colorspace
    bsdf
    hair
    image_colorspace
    image_data_types
    image_mapping
    image_texture_limit
    integrator
    light
    light_group
    light_linking
    mesh
    node_inlining
    pointcloud
    principled_bsdf
    shader
    shadow_catcher
    sss
    texture
  )

  if(WITH_OPENSUBDIV)
    list(APPEND render_tests displacement)
  endif()

  if(WITH_FREESTYLE)
    list(APPEND render_tests render_layer)
  endif()

  if(WITH_MOD_FLUID)
    list(APPEND render_tests motion_blur reports volume)
  endif()

  if(WITH_OPENVDB AND WITH_MOD_FLUID)
    # Some tests in the OpenVDB folder make use of fluid simulations to generate smoke
    list(APPEND render_tests openvdb)
  endif()

  if(WITH_OPENIMAGEDENOISE)
    list(APPEND render_tests denoise)
  endif()

  # Disabled until new OpenPGL version with deterministic results.
  # if(WITH_CYCLES_PATH_GUIDING)
  #   list(APPEND render_tests guiding)
  # endif()

  if(WITH_GPU_RENDER_TESTS)
    list(APPEND render_tests grease_pencil)
  endif()

  list(SORT render_tests)

  # Cycles
  if(WITH_CYCLES)
    set(_cycles_blocklist "")
    set(_cycles_all_test_devices CPU CUDA OPTIX HIP HIP-RT METAL METAL-RT ONEAPI ONEAPI-RT)
    set(_cycles_osl_test_devices CPU OPTIX)
    foreach(_cycles_device ${CYCLES_TEST_DEVICES})
      if(NOT ${_cycles_device} IN_LIST _cycles_all_test_devices)
        message(FATAL_ERROR "Unknown Cycles test device ${_cycles_device}."
            "Supported devices are: ${_cycles_all_test_devices}")
      endif()
      string(TOLOWER "${_cycles_device}" _cycles_device_lower)
      set(_cycles_render_tests bake;${render_tests};osl)

      set(_cycles_osl_test_type none)
      if(WITH_CYCLES_OSL)
        # If the render device is CPU, or a GPU WITH_CYCLES_TEST_OSL enabled,
        # then enable the limited OSL tests (Tests OSL camera with OSL shading turned off).
        # This specific configuration is chosen to avoid long test times on the GPU due to
        # OSL JIT compilation, unless the developer explicitly enables OSL tests.
        if(("${_cycles_device_lower}" STREQUAL "cpu") OR (WITH_CYCLES_TEST_OSL AND ${_cycles_device} IN_LIST _cycles_osl_test_devices))
          set(_cycles_osl_test_type limited)
        endif()
      endif()

      foreach(render_test ${_cycles_render_tests})
        set(_cycles_test_name "cycles_${render_test}_${_cycles_device_lower}")
        if(NOT(WITH_CYCLES_TEST_OSL AND WITH_CYCLES_OSL AND ("${render_test}" STREQUAL "osl")))
          # Only run OSL specific tests during this phase if WITH_CYCLES_TEST_OSL isn't enabled
          add_render_test(
            ${_cycles_test_name}
            ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
            --testdir "${TEST_SRC_DIR}/render/${render_test}"
            --outdir "${TEST_OUT_DIR}/cycles"
            --device ${_cycles_device}
            --osl "${_cycles_osl_test_type}"
          )
          if(NOT ("${_cycles_device_lower}" STREQUAL "cpu"))
            set_tests_properties(${_cycles_test_name} PROPERTIES RUN_SERIAL TRUE)
          endif()
        endif()

        # OSL variations of every test if WITH_CYCLES_TEST_OSL is set.
        if(WITH_CYCLES_TEST_OSL AND NOT "${_cycles_osl_test_type}" STREQUAL "none")
          add_render_test(
            ${_cycles_test_name}_osl
            ${CMAKE_CURRENT_LIST_DIR}/cycles_render_tests.py
            --testdir "${TEST_SRC_DIR}/render/${render_test}"
            --outdir "${TEST_OUT_DIR}/cycles_osl"
            --device ${_cycles_device}
            --osl "all"
          )
          if(NOT ("${_cycles_device_lower}" STREQUAL "cpu"))
            set_tests_properties(${_cycles_test_name}_osl PROPERTIES RUN_SERIAL TRUE)
          endif()
        endif()

        unset(_cycles_test_name)
      endforeach()
      unset(_cycles_osl_test_type)
    endforeach()
    unset(_cycles_osl_test_devices)
    unset(_cycles_all_test_devices)
  endif()

  if(WITH_GPU_RENDER_TESTS)
    list(APPEND gpu_render_tests ${render_tests})
    list(FILTER gpu_render_tests EXCLUDE REGEX light_group|shadow_catcher|denoise|guiding|reports)

    set(_gpu_render_tests_arguments)

    # EEVEE
    if(WITH_OPENGL_BACKEND)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          eevee_opengl_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/eevee_opengl"
          --gpu-backend opengl
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    if(WITH_METAL_BACKEND)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          eevee_metal_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/eevee_metal"
          --gpu-backend metal
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    if(WITH_VULKAN_BACKEND AND WITH_GPU_RENDER_TESTS_VULKAN)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          eevee_vulkan_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/eevee_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/eevee_vulkan"
          --gpu-backend vulkan
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    # Workbench
    if(WITH_OPENGL_BACKEND)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          workbench_opengl_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/workbench_opengl"
          --gpu-backend opengl
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    if(WITH_METAL_BACKEND)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          workbench_metal_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/workbench_metal"
          --gpu-backend metal
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    if(WITH_VULKAN_BACKEND AND WITH_GPU_RENDER_TESTS_VULKAN)
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          workbench_vulkan_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/workbench_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/workbench_vulkan"
          --gpu-backend vulkan
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()

    # Overlay
    if(WITH_GPU_RENDER_TESTS_HEADED)
      if(WITH_OPENGL_BACKEND)
        add_render_test(
          overlay_opengl
          ${CMAKE_CURRENT_LIST_DIR}/overlay_render_tests.py
          --testdir "${TEST_SRC_DIR}/overlay"
          --outdir "${TEST_OUT_DIR}/overlay"
          --gpu-backend opengl
          ${_gpu_render_tests_arguments}
        )
      endif()

      if(WITH_METAL_BACKEND)
        add_render_test(
          overlay_metal
          ${CMAKE_CURRENT_LIST_DIR}/overlay_render_tests.py
          --testdir "${TEST_SRC_DIR}/overlay"
          --outdir "${TEST_OUT_DIR}/overlay"
          --gpu-backend metal
          ${_gpu_render_tests_arguments}
        )
      endif()

      if(WITH_VULKAN_BACKEND AND WITH_GPU_RENDER_TESTS_VULKAN)
        add_render_test(
          overlay_vulkan
          ${CMAKE_CURRENT_LIST_DIR}/overlay_render_tests.py
          --testdir "${TEST_SRC_DIR}/overlay"
          --outdir "${TEST_OUT_DIR}/overlay"
          --gpu-backend vulkan
          ${_gpu_render_tests_arguments}
        )
      endif()
    endif()

    if(WITH_HYDRA)
      # Hydra Storm
      foreach(render_test ${gpu_render_tests})
        add_render_test(
          storm_hydra_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/storm_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/storm_hydra"
          --export_method "HYDRA"
          ${_gpu_render_tests_arguments}
        )
      endforeach()

      foreach(render_test ${gpu_render_tests})
        add_render_test(
          storm_usd_${render_test}
          ${CMAKE_CURRENT_LIST_DIR}/storm_render_tests.py
          --testdir "${TEST_SRC_DIR}/render/${render_test}"
          --outdir "${TEST_OUT_DIR}/storm_usd"
          --export_method "USD"
          ${_gpu_render_tests_arguments}
        )
      endforeach()
    endif()
    unset(_gpu_render_tests_arguments)
  endif()
endif()

# ------------------------------------------------------------------------------
# COMPOSITOR TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  set(compositor_tests
    input
    output
    color
    filter
    texture
    utilities
    vector
    group

    pixel_nodes
    multiple_node_setups
  )

  if(WITH_LIBMV)
    list(APPEND compositor_tests keying mask tracking transform anisotropic_filtering)
  endif()

  foreach(comp_test ${compositor_tests})
    add_render_test(
      compositor_cpu_${comp_test}
      ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py
      --testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
      --outdir "${TEST_OUT_DIR}/compositor_cpu"
    )
  endforeach()

  add_blender_test(
    compositor_cpu_file_output
    --python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
    --
    --testdir "${TEST_SRC_DIR}/compositor/file_output/"
    --outdir "${TEST_OUT_DIR}/compositor_cpu/file_output"
  )
endif()

if(WITH_GPU_COMPOSITOR_TESTS AND TEST_SRC_DIR_EXISTS)
  set(compositor_tests
    input
    output
    color
    filter
    texture
    utilities
    vector
    group

    pixel_nodes
    multiple_node_setups
  )

  if(WITH_LIBMV)
    list(APPEND compositor_tests keying mask tracking transform)
  endif()

  if(WITH_OPENGL_BACKEND)
    foreach(comp_test ${compositor_tests})
      add_render_test(
        compositor_opengl_${comp_test}
        ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py
        --testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
        --outdir "${TEST_OUT_DIR}/compositor_opengl"
        --gpu-backend opengl
      )
    endforeach()
    add_blender_test(
      compositor_opengl_file_output
      --python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
      --
      --testdir "${TEST_SRC_DIR}/compositor/file_output/"
      --outdir "${TEST_OUT_DIR}/compositor_opengl/file_output"
      --gpu-backend opengl
    )
  endif()
  if(WITH_METAL_BACKEND)
    foreach(comp_test ${compositor_tests})
      add_render_test(
        compositor_metal_${comp_test}
        ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py
        --testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
        --outdir "${TEST_OUT_DIR}/compositor_metal"
        --gpu-backend metal
      )
    endforeach()
    add_blender_test(
      compositor_metal_file_output
      --python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
      --
      --testdir "${TEST_SRC_DIR}/compositor/file_output/"
      --outdir "${TEST_OUT_DIR}/compositor_metal/file_output"
      --gpu-backend metal
    )
  endif()
  if(WITH_VULKAN_BACKEND)
    foreach(comp_test ${compositor_tests})
      add_render_test(
        compositor_vulkan_${comp_test}
        ${CMAKE_CURRENT_LIST_DIR}/compositor_render_tests.py
        --testdir "${TEST_SRC_DIR}/compositor/${comp_test}"
        --outdir "${TEST_OUT_DIR}/compositor_vulkan"
        --gpu-backend vulkan
      )
    endforeach()
    add_blender_test(
      compositor_vulkan_file_output
      --python ${CMAKE_CURRENT_LIST_DIR}/compositor_file_output_tests.py
      --
      --testdir "${TEST_SRC_DIR}/compositor/file_output/"
      --outdir "${TEST_OUT_DIR}/compositor_vulkan/file_output"
      --gpu-backend vulkan
    )
  endif()
endif()

add_blender_test(
  compositing_node_group
  --python ${CMAKE_CURRENT_LIST_DIR}/compositing_node_group.py
)

# ------------------------------------------------------------------------------
# GEOMETRY NODE TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  set(geo_node_tests
    attributes
    closure
    curve_primitives
    curves
    curves/interpolate_curves
    foreach_geometry_element_zone
    geometry
    grease_pencil
    import
    instance
    list
    repeat_zone
    mesh_primitives
    mesh
    mesh/extrude
    mesh/split_edges
    mesh/triangulate
    points
    texture
    utilities
    vector
  )

  if(WITH_GMP)
    list(APPEND geo_node_tests mesh/boolean)
  endif()

  if(WITH_OPENVDB)
    list(APPEND geo_node_tests volume)
  endif()

  if(WITH_OPENSUBDIV)
    list(APPEND geo_node_tests mesh/subdivision_tests)
  endif()

  foreach(geo_node_test ${geo_node_tests})
    file(GLOB files "${TEST_SRC_DIR}/modeling/geometry_nodes/${geo_node_test}/*.blend")
    foreach(file ${files})
      get_filename_component(filename ${file} NAME_WE)
      add_blender_test(
        geo_node_${geo_node_test}_${filename}
        ${file}
        --python ${TEST_PYTHON_DIR}/geo_node_test.py
      )
    endforeach()
  endforeach()

  file(GLOB files "${TEST_SRC_DIR}/modeling/geometry_nodes/simulation/*.blend")
  foreach(file ${files})
    get_filename_component(filename ${file} NAME_WE)
    add_blender_test(
      geo_node_simulation_test_${filename}
      ${file}
      --python ${TEST_PYTHON_DIR}/geo_node_sim_test.py
    )
  endforeach()
endif()

# ------------------------------------------------------------------------------
# SCREENSHOT TESTS
# ------------------------------------------------------------------------------

if(WITH_GPU_RENDER_TESTS AND TEST_SRC_DIR_EXISTS)
  set(render_tests
  )

  if(WITH_TESTS_EXPERIMENTAL)
    # The viewport tests are flakey and difficult to keep up to date for use
    # in a CI environment due to constantly changing UI, but may still be helpful
    # for local development.
    #
    # Additionally, they do not currently succeed in an ASAN build. (2025-01-29)
    list(APPEND render_tests viewport)
  endif()

  foreach(render_test ${render_tests})
    add_render_test(
      screenshot_${render_test}
      ${CMAKE_CURRENT_LIST_DIR}/ui_screenshot_tests.py
      --testdir "${TEST_SRC_DIR}/screenshot/${render_test}"
      --outdir "${TEST_OUT_DIR}/screenshot"
    )
  endforeach()
endif()

# ------------------------------------------------------------------------------
# I/O TESTS
# ------------------------------------------------------------------------------

if(WITH_ALEMBIC AND TEST_SRC_DIR_EXISTS)
  find_package_wrapper(Alembic)
  if(NOT ALEMBIC_FOUND)
    message(FATAL_ERROR "Alembic is enabled but cannot be found")
  endif()
  get_filename_component(real_include_dir ${ALEMBIC_INCLUDE_DIR} REALPATH)
  get_filename_component(ALEMBIC_ROOT_DIR ${real_include_dir} DIRECTORY)

  add_python_test(
    io_alembic_export_tests
    ${CMAKE_CURRENT_LIST_DIR}/alembic_export_tests.py
    --blender "${TEST_BLENDER_EXE}"
    --testdir "${TEST_SRC_DIR}/alembic"
    --alembic-root "${ALEMBIC_ROOT_DIR}"
  )

  add_blender_test(
    script_alembic_io
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_alembic_io_test.py
    --
    --testdir "${TEST_SRC_DIR}/alembic"
    --outdir "${TEST_OUT_DIR}/io_alembic"
  )
endif()

if(WITH_USD AND TEST_SRC_DIR_EXISTS)
  add_blender_test(
    io_usd_export
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_usd_export_test.py
    --
    --testdir "${TEST_SRC_DIR}/usd"
  )
  add_blender_test(
    io_usd_import
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_usd_import_test.py
    --
    --testdir "${TEST_SRC_DIR}/usd"
    --outdir "${TEST_OUT_DIR}/io_usd"
  )
endif()

if(TEST_SRC_DIR_EXISTS)
  add_blender_test_allow_error(
    io_fbx_import
    --python ${CMAKE_CURRENT_LIST_DIR}/io_fbx_import_test.py
    --
    --testdir "${TEST_SRC_DIR}/io_tests/fbx"
    --outdir "${TEST_OUT_DIR}/io_fbx"
  )
endif()

if(WITH_IO_WAVEFRONT_OBJ AND TEST_SRC_DIR_EXISTS)
  add_blender_test_allow_error(
    io_obj_import
    --python ${CMAKE_CURRENT_LIST_DIR}/io_obj_import_test.py
    --
    --testdir "${TEST_SRC_DIR}/io_tests/obj"
    --outdir "${TEST_OUT_DIR}/io_obj"
  )
endif()

if(WITH_IO_PLY AND TEST_SRC_DIR_EXISTS)
  add_blender_test_allow_error(
    io_ply_import
    --python ${CMAKE_CURRENT_LIST_DIR}/io_ply_import_test.py
    --
    --testdir "${TEST_SRC_DIR}/io_tests/ply"
    --outdir "${TEST_OUT_DIR}/io_ply"
  )
endif()

if(WITH_IO_STL AND TEST_SRC_DIR_EXISTS)
  add_blender_test_allow_error(
    io_stl_import
    --python ${CMAKE_CURRENT_LIST_DIR}/io_stl_import_test.py
    --
    --testdir "${TEST_SRC_DIR}/io_tests/stl"
    --outdir "${TEST_OUT_DIR}/io_stl"
  )
endif()

if(WITH_CODEC_FFMPEG AND TEST_SRC_DIR_EXISTS)
  add_python_test(
    ffmpeg
    ${CMAKE_CURRENT_LIST_DIR}/ffmpeg_tests.py
    --blender "${TEST_BLENDER_EXE}"
    --testdir "${TEST_SRC_DIR}/ffmpeg"
  )
endif()

if(TEST_SRC_DIR_EXISTS AND TEST_OPENIMAGEIO_TOOL_EXISTS)
  set(OPTIONAL_FORMATS "")
  if(WITH_IMAGE_CINEON)
    set(OPTIONAL_FORMATS "${OPTIONAL_FORMATS} CINEON")
  endif()
  if(WITH_IMAGE_OPENEXR)
    set(OPTIONAL_FORMATS "${OPTIONAL_FORMATS} OPENEXR")
  endif()
  if(WITH_IMAGE_OPENJPEG)
    set(OPTIONAL_FORMATS "${OPTIONAL_FORMATS} OPENJPEG")
  endif()
  if(WITH_IMAGE_WEBP)
    set(OPTIONAL_FORMATS "${OPTIONAL_FORMATS} WEBP")
  endif()

  add_blender_test(
    imbuf_save
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_imbuf_save.py
    --
    -test_dir "${TEST_SRC_DIR}/imbuf_io"
    -output_dir "${TEST_OUT_DIR}/imbuf_io/save"
    -oiiotool "${OPENIMAGEIO_TOOL}"
    -optional_formats "${OPTIONAL_FORMATS}"
  )

  add_blender_test_allow_error(
    imbuf_load
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_imbuf_load.py
    --
    -test_dir "${TEST_SRC_DIR}/imbuf_io"
    -output_dir "${TEST_OUT_DIR}/imbuf_io/load"
    -oiiotool "${OPENIMAGEIO_TOOL}"
    -optional_formats "${OPTIONAL_FORMATS}"
  )
endif()

# ------------------------------------------------------------------------------
# SEQUENCER RENDER TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  set(render_tests
    effects
    filter
    transform
    blend_modes_byte
    blend_modes_float
    ffmpeg
  )

  set(video_output_tests
    video_output
  )

  foreach(render_test ${render_tests})
    add_render_test(
      sequencer_render_${render_test}
      ${CMAKE_CURRENT_LIST_DIR}/sequencer_render_tests.py
      --testdir "${TEST_SRC_DIR}/sequence_editing/${render_test}"
      --outdir "${TEST_OUT_DIR}/sequence_editing"
    )
  endforeach()

  foreach(video_output_test ${video_output_tests})
    add_render_test(
      sequencer_render_${video_output_test}
      ${CMAKE_CURRENT_LIST_DIR}/sequencer_video_output_tests.py
      --testdir "${TEST_SRC_DIR}/sequence_editing/${video_output_test}"
      --outdir "${TEST_OUT_DIR}/sequence_editing"
    )
  endforeach()

  add_blender_test(
    sequencer_input_colorspace
    --python ${CMAKE_CURRENT_LIST_DIR}/sequencer_input_colorspace.py
    --
    --testdir "${TEST_SRC_DIR}/sequence_editing"
  )

  add_blender_test(
    sequencer_load_meta_stack
    ${TEST_SRC_DIR}/sequence_editing/vse_load_meta_stack.blend
    --python ${TEST_PYTHON_DIR}/sequencer_load_meta_stack.py
  )
endif()

# ------------------------------------------------------------------------------
# SCULPTING TESTS
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  add_blender_test(
    bl_sculpt_operators
    --python ${CMAKE_CURRENT_LIST_DIR}/bl_sculpt.py
    --
    --testdir "${TEST_SRC_DIR}/sculpting"
  )

  add_blender_test(
    bl_sculpt_brush_curve_presets
    --python ${CMAKE_CURRENT_LIST_DIR}/sculpt_paint/brush_strength_curves_test.py
    --
    --testdir "${TEST_SRC_DIR}/sculpting"
  )

  add_blender_test(
    bl_sculpt_mask_filter
    --python ${CMAKE_CURRENT_LIST_DIR}/sculpt_paint/mask_filter_test.py
    --
    --testdir "${TEST_SRC_DIR}/sculpting"
  )
endif()

if(WITH_GPU_MESH_PAINT_TESTS AND TEST_SRC_DIR_EXISTS)
  set(render_tests
    brushes
  )

  foreach(render_test ${render_tests})
    add_render_test(
      sculpt_render_${render_test}
      ${CMAKE_CURRENT_LIST_DIR}/sculpt_brush_render_tests.py
      --testdir "${TEST_SRC_DIR}/sculpting/${render_test}"
      --outdir "${TEST_OUT_DIR}/sculpting"
    )
  endforeach()
endif()


# ------------------------------------------------------------------------------
# Headless GUI Tests
# ------------------------------------------------------------------------------

if(WITH_UI_TESTS)
  # This could be generated with:
  # `"${TEST_PYTHON_EXE}" "${CMAKE_CURRENT_LIST_DIR}/ui_simulate/run.py" --list-tests`
  # list explicitly so changes bisecting/updated are sure to re-run CMake.
  set(_ui_tests
    test_sculpt.asset_shelf_brush_selection
    test_tools.sculpt_mode_toolbar
    test_undo.compositor_make_group
    test_undo.text_editor_edit_mode_mix
    test_undo.text_editor_simple
    test_undo.view3d_edit_mode_multi_window
    test_undo.view3d_font_edit_mode_simple
    test_undo.view3d_mesh_edit_separate
    test_undo.view3d_mesh_particle_edit_mode_simple
    test_undo.view3d_multi_mode_multi_window
    test_undo.view3d_multi_mode_select
    test_undo.view3d_sculpt_dyntopo_and_edit
    test_undo.view3d_sculpt_dyntopo_simple
    test_undo.view3d_sculpt_dyntopo_stroke_toggle
    test_undo.view3d_sculpt_with_memfile_step
    test_undo.view3d_sculpt_trim
    test_undo.view3d_simple
    test_undo.view3d_texture_paint_complex
    test_undo.view3d_texture_paint_simple
    test_workspace.sanity_check_general
    test_workspace.sanity_check_2d_animation
    test_workspace.sanity_check_sculpting
    test_workspace.sanity_check_storyboarding
    test_workspace.sanity_check_vfx
    test_workspace.sanity_check_video_editing
  )
  foreach(ui_test ${_ui_tests})
    add_blender_test_ui(
      "ui_${ui_test}"
      --enable-event-simulate
      --python "${CMAKE_CURRENT_LIST_DIR}/ui_simulate/run_blender_setup.py"
      --
      --tests "${ui_test}"
    )
  endforeach()
  unset(_ui_tests)
endif()


# ------------------------------------------------------------------------------
# VIEW LAYER Tests
# ------------------------------------------------------------------------------

if(TEST_SRC_DIR_EXISTS)
  # TODO: disabled for now after collection unification
  # add_subdirectory(view_layer)
endif()

# ------------------------------------------------------------------------------
# Linux Release sainty checks
# ------------------------------------------------------------------------------

if(WITH_LINUX_OFFICIAL_RELEASE_TESTS)
  get_filename_component(release_root_folder ${TEST_BLENDER_EXE} DIRECTORY)
  set(extra_args "")
  if(WITH_COMPILER_ASAN)
    set(extra_args
      ${extra_args}
      --sanitizer-build
    )
  endif()
  add_python_test(
    linux_release_sanity_checks
    ${CMAKE_SOURCE_DIR}/tools/check_blender_release/check_release.py
    -- --directory "${release_root_folder}" ${extra_args}
  )
  unset(extra_args)
  unset(release_root_folder)
endif()