[PATCH 2/7] core: Updated infrastructure to support python tests
- From: Simón Pena <spenap gmail com>
- To: grilo-list gnome org
- Subject: [PATCH 2/7] core: Updated infrastructure to support python tests
- Date: Tue, 21 Sep 2010 20:35:41 +0200
* 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
---
configure.ac | 2 ++
tests/Makefile.am | 6 ++----
tests/python/Makefile.am | 19 +++++++++++++++++++
tests/python/testrunner.py | 19 +++++++++++++++++++
tests/python/util.py.in | 9 +++++++++
5 files changed, 51 insertions(+), 4 deletions(-)
create mode 100644 tests/python/Makefile.am
create mode 100755 tests/python/testrunner.py
create mode 100644 tests/python/util.py.in
diff --git a/configure.ac b/configure.ac
index f2d1cfe..0dfa6f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,6 +201,8 @@ AC_CONFIG_FILES([
grilo-0.1.pc
src/Makefile
tests/Makefile
+ tests/python/Makefile
+ tests/python/util.py
tools/Makefile
tools/grilo-test-ui/Makefile
tools/grilo-inspect/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 95c24a9..aa886d1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = . python
+
# things to test
noinst_PROGRAMS = $(TEST_PROGS)
@@ -16,10 +18,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..3b9b57f
--- /dev/null
+++ b/tests/python/Makefile.am
@@ -0,0 +1,19 @@
+# things to test
+
+test: testrunner.py
+if HAVE_INTROSPECTION
+ PYTHONPATH=$(top_builddir):$(top_builddir)/src/tests/python:$${PYTHONPATH:+$$PYTHONPATH:} $(PYTHON) $(srcdir)/testrunner.py
+endif
+
+if HAVE_INTROSPECTION
+EXTRA_DIST = \
+ runtests.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..f82d51d
--- /dev/null
+++ b/tests/python/testrunner.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+import unittest
+import glob
+
+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'''
--
1.7.0.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]