[PATCH 1/2] 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
* Updated test's Makefile.am to also launch Python tests
  when 'make check' is invoked
---
 configure.ac            |    1 +
 src/tests/Makefile.am   |   15 +++++++++++++--
 src/tests/testrunner.py |   19 +++++++++++++++++++
 src/tests/util.py.in    |    9 +++++++++
 4 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100755 src/tests/testrunner.py
 create mode 100644 src/tests/util.py.in

diff --git a/configure.ac b/configure.ac
index a8207b5..e488df2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -201,6 +201,7 @@ AC_CONFIG_FILES([
   grilo-0.1.pc
   src/Makefile
   src/tests/Makefile
+  src/tests/util.py
   tools/Makefile
   tools/grilo-test-ui/Makefile
   tools/grilo-inspect/Makefile
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 44e2f1e..e3c0be7 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -14,13 +14,24 @@ registry_LDADD = $(progs_ldadd)
 GTESTER = gtester
 
 # test: run all tests in cwd and subdirs
-test:	${TEST_PROGS}
+c_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
 
+python_test: testrunner.py
+if HAVE_INTROSPECTION
+	PYTHONPATH=$(top_builddir):$(top_builddir)/src/tests$${PYTHONPATH:+:$$PYTHONPATH} $(PYTHON) $(srcdir)/testrunner.py
+endif
+
+if HAVE_INTROSPECTION
+EXTRA_DIST = \
+	runtests.py \
+	test_registry.py
+endif
+
 # test-report: run tests in subdirs and generate report
 # perf-report: run tests in subdirs with -m perf and generate report
 # full-report: like test-report: with -m perf and -m slow
@@ -59,5 +70,5 @@ test-report perf-report full-report:	${TEST_PROGS}
 	  }
 .PHONY: test test-report perf-report full-report
 # run make test as part of make check
-check-local: test
+check-local: c_test python_test
 
diff --git a/src/tests/testrunner.py b/src/tests/testrunner.py
new file mode 100755
index 0000000..f82d51d
--- /dev/null
+++ b/src/tests/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/src/tests/util.py.in b/src/tests/util.py.in
new file mode 100644
index 0000000..365c349
--- /dev/null
+++ b/src/tests/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]