CInema: Migrate to using ini manifests

This commit is contained in:
Vicki Pfau 2020-06-16 18:18:34 -07:00
parent 0de8f432ec
commit 11b8167708
66 changed files with 109 additions and 66 deletions

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=SGB

View File

@ -1,3 +0,0 @@
config:
gb.model: SGB
fail: true

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -1 +0,0 @@
fail: true

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=SGB

View File

@ -1,3 +0,0 @@
config:
gb.model: SGB
fail: true

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=SGB

View File

@ -1,2 +0,0 @@
config:
gb.model: SGB

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=MGB

View File

@ -1,2 +0,0 @@
config:
gb.model: MGB

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=SGB

View File

@ -1,2 +0,0 @@
config:
gb.model: SGB

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=SGB2

View File

@ -1,2 +0,0 @@
config:
gb.model: SGB2

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -1 +0,0 @@
fail: true

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -1 +0,0 @@
fail: true

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,6 @@
[testinfo]
skip=60
frames=1
[ports.cinema]
sgb.borders=0

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -1,4 +0,0 @@
skip: 60
frames: 1
config:
sgb.borders: false

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=CGB

View File

@ -1,3 +0,0 @@
config:
gb.model: CGB
fail: true

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=AGB

View File

@ -1,3 +0,0 @@
config:
gb.model: AGB
fail: true

View File

@ -0,0 +1,2 @@
[testinfo]
fail=1

View File

@ -1 +0,0 @@
fail: true

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=CGB

View File

@ -1 +0,0 @@
fail: true

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=CGB

View File

@ -1,3 +0,0 @@
config:
gb.model: CGB
fail: true

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=AGB

View File

@ -1,2 +0,0 @@
config:
gb.model: AGB

View File

@ -0,0 +1,2 @@
[ports.cinema]
gb.model=CGB

View File

@ -1,2 +0,0 @@
config:
gb.model: CGB

View File

@ -0,0 +1,5 @@
[testinfo]
fail=1
[ports.cinema]
gb.model=CGB

View File

@ -1,3 +0,0 @@
config:
gb.model: CGB
fail: true

View File

@ -6,10 +6,10 @@ import cinema.movie
import itertools
import glob
import re
import yaml
from copy import deepcopy
from cinema import VideoFrame
from cinema.util import dict_merge
from configparser import ConfigParser
class CinemaTest(object):
@ -22,8 +22,15 @@ class CinemaTest(object):
self.name = '.'.join(path)
self.settings = settings
try:
with open(os.path.join(self.path, 'manifest.yml'), 'r') as f:
dict_merge(self.settings, yaml.safe_load(f))
with open(os.path.join(self.path, 'config.ini'), 'r') as f:
cfg = ConfigParser()
cfg.read_file(f)
settings = {}
if 'testinfo' in cfg:
settings = dict(cfg['testinfo'])
if 'ports.cinema' in cfg:
settings['config'] = dict(cfg['ports.cinema'])
dict_merge(self.settings, settings)
except IOError:
pass
self.tests = {}
@ -49,9 +56,9 @@ class CinemaTest(object):
def output_settings(self):
output_settings = {}
if 'frames' in self.settings:
output_settings['limit'] = self.settings['frames']
output_settings['limit'] = int(self.settings['frames'])
if 'skip' in self.settings:
output_settings['skip'] = self.settings['skip']
output_settings['skip'] = int(self.settings['skip'])
return output_settings
def __lt__(self, other):

View File

@ -3,7 +3,7 @@ import itertools
import os
import os.path
import pytest
import yaml
from configparser import ConfigParser
def pytest_addoption(parser):
parser.addoption("--rebaseline", action="store_true", help="output a new baseline instead of testing")
@ -39,11 +39,12 @@ def pytest_exception_interact(node, call, report):
diffNorm.save(os.path.join(outdir, DIFF_NORM % i))
if node.config.getoption("--mark-failing"):
settings = ConfigParser()
try:
with open(os.path.join(vtest.path, 'manifest.yml'), 'r') as f:
settings = yaml.safe_load(f)
with open(os.path.join(vtest.path, 'config.ini'), 'r') as f:
settings.read_file(f)
except IOError:
settings = {}
settings['fail'] = True
with open(os.path.join(vtest.path, 'manifest.yml'), 'w') as f:
yaml.dump(settings, f, default_flow_style=False)
pass
settings.set('testinfo', 'fail', '1')
with open(os.path.join(vtest.path, 'config.ini'), 'w') as f:
settings.write(f)

View File

@ -23,7 +23,7 @@ setup(
packages=["mgba"],
setup_requires=['cffi>=1.6', 'pytest-runner'],
install_requires=['cffi>=1.6', 'cached-property'],
extras_require={'pil': ['Pillow>=2.3'], 'cinema': ['pyyaml', 'pytest']},
extras_require={'pil': ['Pillow>=2.3'], 'cinema': ['pytest']},
tests_require=['pytest'],
cffi_modules=["_builder.py:ffi"],
license="MPL 2.0",

View File

@ -24,7 +24,7 @@ def pytest_generate_tests(metafunc):
for test in testList:
marks = []
xfail = test.settings.get('fail')
if xfail:
if xfail and bool(xfail):
marks = pytest.mark.xfail(reason=xfail if isinstance(xfail, str) else None)
params.append(pytest.param(test, id=test.name, marks=marks))
metafunc.parametrize('vtest', params, indirect=True)