Tests: Add test to open all blendfiles in current `/lib/tests/` repository.

This is fairly brute force and rough, but there are quite a few old
files in there, helps a bit with versioning and readfile code testing.

Note: Five files are currently excluded since failing in debug builds
at least, most of the time for memleaks issues. The two other 'errors'
may also not be actual issues, but this needs to be investigated further.

Also, in the future, when time allows, it may be better to generate a
set of dedicated testing files, with as many official releases versions
as possible?

Re. #112649.
This commit is contained in:
Bastien Montagne 2023-10-04 11:28:43 +02:00
parent d071e0a5fc
commit 3d5c6dc218
2 changed files with 107 additions and 0 deletions

View File

@ -160,6 +160,15 @@ add_blender_test(
--output-dir ${TEST_OUT_DIR}/blendfile_io/
)
add_blender_test(
blendfile_versioning
--log "*blendfile*"
--debug-memory
--debug
--python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_versioning.py --
--src-test-dir ${TEST_SRC_DIR}/
)
add_blender_test(
blendfile_liblink
--python ${CMAKE_CURRENT_LIST_DIR}/bl_blendfile_liblink.py --

View File

@ -0,0 +1,98 @@
# SPDX-FileCopyrightText: 2023 Blender Authors
#
# SPDX-License-Identifier: Apache-2.0
# ./blender.bin --background -noaudio --python tests/python/bl_blendfile_versioning.py ..
import bpy
import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
from bl_blendfile_utils import TestHelper
class TestBlendFileOpenAllTestFiles(TestHelper):
def __init__(self, args):
self.args = args
# Some files are known broken currently.
# Each file in this list should either be the source of a bug report,
# or removed from tests repo.
self.excluded_paths = {
# tests/modifier_stack/explode_modifier.blend
# BLI_assert failed: source/blender/blenlib/BLI_ordered_edge.hh:41, operator==(), at 'e1.v_low < e1.v_high'
"explode_modifier.blend",
# tests/depsgraph/deg_anim_camera_dof_driving_material.blend
# ERROR (bke.fcurve): source/blender/blenkernel/intern/fcurve_driver.cc:188 dtar_get_prop_val: Driver Evaluation Error: cannot resolve target for OBCamera -> data.dof_distance
"deg_anim_camera_dof_driving_material.blend",
# tests/depsgraph/deg_driver_shapekey_same_datablock.blend
# Error: Not freed memory blocks: 4, total unfreed memory 0.000427 MB
"deg_driver_shapekey_same_datablock.blend",
# tests/physics/fluidsim.blend
# Error: Not freed memory blocks: 3, total unfreed memory 0.003548 MB
"fluidsim.blend",
# tests/opengl/ram_glsl.blend
# Error: Not freed memory blocks: 4, total unfreed memory 0.000427 MB
"ram_glsl.blend",
}
@classmethod
def iter_blendfiles_from_directory(cls, root_path):
for dir_entry in os.scandir(root_path):
if dir_entry.is_dir(follow_symlinks=False):
yield from cls.iter_blendfiles_from_directory(dir_entry.path)
elif dir_entry.is_file(follow_symlinks=False):
if os.path.splitext(dir_entry.path)[1] == ".blend":
yield dir_entry.path
def test_open(self):
import subprocess
blendfile_paths = [p for p in self.iter_blendfiles_from_directory(self.args.src_test_dir)]
# `os.scandir()` used by `iter_blendfiles_from_directory` does not
# guarantee any form of order.
blendfile_paths.sort()
for bfp in blendfile_paths:
if os.path.basename(bfp) in self.excluded_paths:
continue
bpy.ops.wm.read_homefile(use_empty=True, use_factory_startup=True)
bpy.ops.wm.open_mainfile(filepath=bfp, load_ui=False)
TESTS = (
TestBlendFileOpenAllTestFiles,
)
def argparse_create():
import argparse
# When --help or no args are given, print this help
description = ("Test basic versioning code by opening all blend files "
"in `lib/tests` directory.")
parser = argparse.ArgumentParser(description=description)
parser.add_argument(
"--src-test-dir",
dest="src_test_dir",
default="..",
help="Root tests directory to search for blendfiles",
required=False,
)
return parser
def main():
args = argparse_create().parse_args()
for Test in TESTS:
Test(args).run_all_tests()
if __name__ == '__main__':
import sys
sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])
main()