summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimón Pena <spenap@gmail.com>2010-09-29 16:30:57 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2010-09-30 17:21:23 +0200
commita0fb48d0348eaf2eab1cbcf1bca22e75953ebed6 (patch)
tree1318b254239c75164c030c422c02849381dae377 /tests
parent50fc74eab57720b34451273c3f00c597cfe5c551 (diff)
downloadgrilo-a0fb48d0348eaf2eab1cbcf1bca22e75953ebed6.tar.gz
core: Updated infrastructure to support python tests
* Update configure.ac to generate a 'util' Python class * Added a test runner to launch Python unit tests * Added python/ to tests' SUBDIRS * Updated test's Makefile.am to avoid launching Python tests twice when 'make check' is invoked
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/python/Makefile.am22
-rwxr-xr-xtests/python/testrunner.py21
-rw-r--r--tests/python/util.py.in9
4 files changed, 58 insertions, 4 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 95c24a9..ab52607 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,9 @@
+SUBDIRS = .
+
+if HAVE_INTROSPECTION
+SUBDIRS += python
+endif
+
# things to test
noinst_PROGRAMS = $(TEST_PROGS)
@@ -16,10 +22,6 @@ GTESTER = gtester
# test: run all tests in cwd and subdirs
test: ${TEST_PROGS}
@test -z "${TEST_PROGS}" || ${GTESTER} --verbose ${TEST_PROGS}
- @ for subdir in $(SUBDIRS) . ; do \
- test "$$subdir" = "." -o "$$subdir" = "po" || \
- ( cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $? ; \
- done
# test-report: run tests in subdirs and generate report
# perf-report: run tests in subdirs with -m perf and generate report
diff --git a/tests/python/Makefile.am b/tests/python/Makefile.am
new file mode 100644
index 0000000..b4c053a
--- /dev/null
+++ b/tests/python/Makefile.am
@@ -0,0 +1,22 @@
+# things to test
+
+test: testrunner.py
+if HAVE_INTROSPECTION
+ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(top_builddir)/src/.libs/ \
+ GI_TYPELIB_PATH=${GI_TYPELIB_PATH}:$(top_builddir)/src/ \
+ PYTHONPATH=$(top_builddir):$(top_builddir)/src/tests/python:$${PYTHONPATH:+$$PYTHONPATH:} \
+ $(PYTHON) $(srcdir)/testrunner.py
+endif
+
+if HAVE_INTROSPECTION
+EXTRA_DIST = \
+ testrunner.py
+endif
+
+.PHONY: test test-report perf-report full-report
+# run make test as part of make check
+check-local: test
+
+MAINTAINERCLEANFILES = \
+ *.pyc \
+ Makefile.in
diff --git a/tests/python/testrunner.py b/tests/python/testrunner.py
new file mode 100755
index 0000000..af8e3d0
--- /dev/null
+++ b/tests/python/testrunner.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import unittest
+import glob
+import pygtk
+pygtk.require('2.0')
+
+test_loader = unittest.defaultTestLoader
+
+names = []
+for filename in glob.iglob("test_*.py"):
+ names.append(filename[:-3])
+
+test_suites = []
+for name in names:
+ test_suites.append(test_loader.loadTestsFromName(name))
+
+runner = unittest.TextTestRunner(verbosity=2)
+
+for suite in test_suites:
+ runner.run(suite)
diff --git a/tests/python/util.py.in b/tests/python/util.py.in
new file mode 100644
index 0000000..365c349
--- /dev/null
+++ b/tests/python/util.py.in
@@ -0,0 +1,9 @@
+import os
+
+GRL_PLUGIN_PATH_VAR = 'GRL_PLUGIN_PATH'
+GRL_PLUGIN_PATH_DEFAULT = '''@GRL_PLUGINS_DIR@'''
+GRL_PLUGIN_PATH = os.getenv(GRL_PLUGIN_PATH_VAR,
+ GRL_PLUGIN_PATH_DEFAULT)
+
+PREFIX = '''@libdir@'''
+GRL_LIB_NAME = '''lib@GRL_NAME@.la'''