CInema: Migrate to using ini manifests
jump to
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=SGB
@@ -1,3 +0,0 @@
-config: - gb.model: SGB -fail: true
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=SGB
@@ -1,3 +0,0 @@
-config: - gb.model: SGB -fail: true
@@ -0,0 +1,2 @@
+[ports.cinema] +gb.model=SGB
@@ -0,0 +1,2 @@
+[ports.cinema] +gb.model=MGB
@@ -1,2 +0,0 @@
-config: - gb.model: MGB
@@ -0,0 +1,2 @@
+[ports.cinema] +gb.model=SGB
@@ -1,2 +0,0 @@
-config: - gb.model: SGB
@@ -0,0 +1,2 @@
+[ports.cinema] +gb.model=SGB2
@@ -1,2 +0,0 @@
-config: - gb.model: SGB2
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,1 +0,0 @@
-fail: true
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,1 +0,0 @@
-fail: true
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,1 +0,0 @@
-fail: true
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,1 +0,0 @@
-fail: true
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,1 +0,0 @@
-fail: true
@@ -0,0 +1,6 @@
+[testinfo] +skip=60 +frames=1 + +[ports.cinema] +sgb.borders=0
@@ -0,0 +1,2 @@
+[testinfo] +fail=1
@@ -1,4 +0,0 @@
-skip: 60 -frames: 1 -config: - sgb.borders: false
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=CGB
@@ -1,3 +0,0 @@
-config: - gb.model: CGB -fail: true
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=AGB
@@ -1,3 +0,0 @@
-config: - gb.model: AGB -fail: true
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=CGB
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=CGB
@@ -1,3 +0,0 @@
-config: - gb.model: CGB -fail: true
@@ -0,0 +1,5 @@
+[testinfo] +fail=1 + +[ports.cinema] +gb.model=CGB
@@ -1,3 +0,0 @@
-config: - gb.model: CGB -fail: true
@@ -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 @@ self.root = root
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 @@
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):
@@ -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 @@ diff.save(os.path.join(outdir, DIFF % i))
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)
@@ -23,7 +23,7 @@ url="http://github.com/mgba-emu/mgba/",
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",
@@ -24,7 +24,7 @@ params = []
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)