Beginning of CLI interface + protection against infinite recursion.

This commit is contained in:
Sybren A. Stüvel
2018-02-28 16:47:13 +01:00
parent 8ae400acbe
commit ca964181fe
14 changed files with 314 additions and 27 deletions
Binary file not shown.
Binary file not shown.
+13
View File
@@ -1,5 +1,6 @@
import collections
import logging
import sys
import typing
from blender_asset_tracer import tracer, blendfile
@@ -203,3 +204,15 @@ class DepsTest(AbstractTracerTest):
'PointCache', 'name[64]', None, None,
b'//blendcache_bam_pack_bug/particles_*.bphys', True),
})
def test_recursion_loop(self):
infinite_bfile = self.blendfiles / 'recursive_dependency_1.blend'
reclim = sys.getrecursionlimit()
try:
sys.setrecursionlimit(80)
# This should finish without hitting the recursion limit.
for _ in tracer.deps(infinite_bfile, recursive=True):
pass
finally:
sys.setrecursionlimit(reclim)
+39
View File
@@ -0,0 +1,39 @@
from abstract_test import AbstractBlendFileTest
from blender_asset_tracer.tracer import file_sequence
class ExpandFileSequenceTest(AbstractBlendFileTest):
def setUp(self):
super().setUp()
self.imgseq = [self.blendfiles / ('imgseq/%06d.png' % num)
for num in range(210, 215)]
def test_glob(self):
path = self.blendfiles / 'imgseq/*.png'
actual = list(file_sequence.expand_sequence(path))
self.assertEqual(self.imgseq, actual)
def test_directory(self):
path = self.blendfiles / 'imgseq'
actual = list(file_sequence.expand_sequence(path))
expected = self.imgseq + [self.blendfiles / 'imgseq/LICENSE.txt']
self.assertEqual(expected, actual)
def test_first_file(self):
path = self.blendfiles / 'imgseq/000210.png'
actual = list(file_sequence.expand_sequence(path))
self.assertEqual(self.imgseq, actual)
def test_nonexistent(self):
path = self.blendfiles / 'nonexistant'
with self.assertRaises(file_sequence.DoesNotExist) as raises:
for result in file_sequence.expand_sequence(path):
self.fail('unexpected result %r' % result)
self.assertEqual(path, raises.exception.path)
def test_non_sequence_file(self):
path = self.blendfiles / 'imgseq/LICENSE.txt'
actual = list(file_sequence.expand_sequence(path))
self.assertEqual([path], actual)