[game-data-packager] 25/25: Turn manual-check into an integration test
Simon McVittie
smcv at debian.org
Sun Oct 9 21:26:07 UTC 2016
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch master
in repository game-data-packager.
commit e0c796eb4d2790a231886e200c13eab7d5152576
Author: Simon McVittie <smcv at debian.org>
Date: Sun Oct 9 21:48:06 2016 +0100
Turn manual-check into an integration test
If GDP_MIRROR isn't set, it uses the XDG download directory; this means
we don't exercise the http download code path, but it also means
we don't need extra infrastructure.
---
Makefile | 24 ++-----------
tests/integration.py | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile
index 9b14d4a..2bb60b9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,3 @@
-GDP_MIRROR ?= localhost
bindir := /usr/games
datadir := /usr/share/games
pkgdatadir := ${datadir}/game-data-packager
@@ -10,17 +9,6 @@ PYFLAKES3 := $(shell if [ -x /usr/bin/pyflakes3 ] ; then echo pyflakes3 ; \
else ls -1 /usr/bin/pyflakes-python3.* | tail -n 1 ; \
fi)
-# some cherry picked games that:
-# - are freely downloadable (either demo or full version)
-# - test various codepaths:
-# - alternatives
-# - archive recursion (zip in zip)
-# - lha
-# - id-shr-extract
-# - doom_commo.py plugin
-# - are not too big
-TEST_SUITE += rott spear-of-destiny wolf3d heretic
-
png_from_xpm := $(patsubst ./data/%.xpm,./out/%.png,$(wildcard ./data/*.xpm))
png_from_svg := $(patsubst ./data/%.svg,./out/%.png,$(wildcard ./data/*.svg))
png := $(png_from_xpm) $(png_from_svg) out/memento-mori.png
@@ -109,6 +97,7 @@ check:
LC_ALL=C $(PYFLAKES3) game_data_packager/*.py game_data_packager/*/*.py runtime/*.py tests/*.py tools/*.py || :
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tests/deb.py
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tests/hashed_file.py
+ LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tests/integration.py
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tests/rpm.py
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tests/umod.py
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. $(PYTHON) tools/check_syntax.py
@@ -160,17 +149,8 @@ install:
install -m0644 doc/doom2-masterlevels.6 $(DESTDIR)/usr/share/man/man6/
install -m0644 out/doom-common.png $(DESTDIR)/usr/share/pixmaps/doom2-masterlevels.png
-# Requires additional setup, so not part of "make check"
-manual-check:
- install -d out/manual-check/
- for game in $(TEST_SUITE); do \
- GDP_MIRROR=$(GDP_MIRROR) GDP_UNINSTALLED=1 PYTHONPATH=. \
- python3 -m game_data_packager.command_line -d ./out/manual-check --no-compress $$game --no-search || exit $$?; \
- done
- rm -fr out/manual-check/
-
html: $(DIRS) $(json)
LC_ALL=C GDP_UNINSTALLED=1 PYTHONPATH=. python3 -m tools.babel
rsync out/index.html alioth.debian.org:/var/lib/gforge/chroot/home/groups/pkg-games/htdocs/game-data/ -e ssh -v
-.PHONY: default clean check manual-check install html
+.PHONY: default clean check install html
diff --git a/tests/integration.py b/tests/integration.py
new file mode 100644
index 0000000..c320d0c
--- /dev/null
+++ b/tests/integration.py
@@ -0,0 +1,97 @@
+#!/usr/bin/python3
+# encoding=utf-8
+#
+# Copyright © 2016 Simon McVittie <smcv at debian.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# You can find the GPL license text on a Debian system under
+# /usr/share/common-licenses/GPL-2.
+
+import os
+import subprocess
+import unittest
+from tempfile import (TemporaryDirectory)
+
+try:
+ from gi.repository import GLib
+except:
+ GLib = None
+
+class IntegrationTestCase(unittest.TestCase):
+ '''
+ Test some cherry picked games that:
+ - are freely downloadable (either demo or full version)
+ - test various codepaths:
+ - alternatives
+ - archive recursion (zip in zip)
+ - lha
+ - id-shr-extract
+ - doom_commo.py plugin
+ - are not too big
+ '''
+
+ def setUp(self):
+ if 'GDP_MIRROR' in os.environ:
+ self.downloads = None
+ else:
+ if GLib is None:
+ self.skipTest('GLib g-i bindings not available')
+
+ self.downloads = GLib.get_user_special_dir(
+ GLib.UserDirectory.DIRECTORY_DOWNLOAD)
+ if (self.downloads is None or
+ not os.path.isdir(self.downloads)):
+ self.skipTest('XDG download directory "{}" not found'.format(
+ self.downloads))
+
+ os.environ['GDP_MIRROR'] = 'file://' + self.downloads
+
+ def _test_one(self, game, files):
+ if 'GDP_MIRROR' not in os.environ:
+ for filename in files:
+ if not os.path.exists(os.path.join(self.downloads, filename)):
+ self.skipTest('download {} into {}'.format(filename,
+ self.downloads))
+
+ with TemporaryDirectory(prefix='gdptest.') as tmp:
+ if 'GDP_UNINSTALLED' in os.environ:
+ argv = ['./run']
+ else:
+ argv = ['game-data-packager']
+
+ argv = argv + [
+ '-d', tmp,
+ '--no-compress',
+ game,
+ '--no-search',
+ ]
+ subprocess.check_call(argv)
+ if 'GDP_TEST_ALL_FORMATS' in os.environ:
+ for f in 'arch deb rpm'.split():
+ subprocess.check_call(argv + ['--target-format', f])
+
+ def test_heretic(self):
+ self._test_one('heretic', 'htic_v12.zip'.split())
+
+ def test_rott(self):
+ self._test_one('rott', '1rott13.zip'.split())
+
+ def test_spear(self):
+ self._test_one('spear-of-destiny', 'sodemo.zip destiny.zip'.split())
+
+ def test_wolf3d(self):
+ self._test_one('wolf3d', '1wolf14.zip'.split())
+
+ def tearDown(self):
+ pass
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/game-data-packager.git
More information about the Pkg-games-commits
mailing list