[PATCH 2/7] 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
---
 configure.ac               |    2 ++
 tests/Makefile.am          |   10 ++++++----
 tests/python/Makefile.am   |   22 ++++++++++++++++++++++
 tests/python/testrunner.py |   21 +++++++++++++++++++++
 tests/python/util.py.in    |    9 +++++++++
 5 files changed, 60 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 e2151f6..931581b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -220,6 +220,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..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'''
-- 
1.7.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]