Re: [PATCH 2/7] core: Updated infrastructure to support python tests
- From: Víctor M. Jáquez L. <vjaquez igalia com>
- To: grilo-list gnome org
- Subject: Re: [PATCH 2/7] core: Updated infrastructure to support python tests
- Date: Tue, 28 Sep 2010 12:30:31 +0200
NAK
On Tue, Sep 21, 2010 at 08:35:41PM +0200, Simón Pena wrote:
> * 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
> +
I reckon that this would be more clear and less verbose in the tests'
Makefile.am
SUBDIRS = .
if HAVE_INTROSPECTION
SUBDIRS += python
endif
> # 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
Testing this patch I had to change this line into these ones:
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
Since normally you shouldn't have installed the Grl typelib when running the
check, also the library isn't installed yet.
> +
> +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
I had to set this snippet here too
import pygtk
pygtk.require('2.0')
Since the line pygtk.require('2.0') adds gi to the pythonpath. Otherwise the
gi support can't be loaded.
> +
> +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'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]