summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am5
-rw-r--r--tests/Makefile.am65
-rw-r--r--tests/common.py47
-rw-r--r--tests/runtests.py43
-rw-r--r--tests/test_gcancellable.py4
-rw-r--r--tests/test_gi.py3
-rw-r--r--tests/test_gicon.py3
-rw-r--r--tests/test_gio.py3
-rw-r--r--tests/test_gobject.py3
-rw-r--r--tests/test_gresolver.py4
-rw-r--r--tests/test_gsocket.py4
-rw-r--r--tests/test_interface.py6
-rw-r--r--tests/test_mainloop.py11
-rw-r--r--tests/test_signal.py4
-rw-r--r--tests/test_source.py4
-rw-r--r--tests/test_subprocess.py5
-rw-r--r--tests/test_thread.py5
-rw-r--r--tests/test_unknown.py5
18 files changed, 82 insertions, 142 deletions
diff --git a/Makefile.am b/Makefile.am
index 94bcf8e1..6fe43c60 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,11 +128,6 @@ dist-hook: $(BUILT_EXTRA_DIST)
check.gdb:
cd tests && $(MAKE) check.gdb
-%.gdb:
- cd tests && $(MAKE) $*.gdb
-
check.valgrind:
cd tests && $(MAKE) check.valgrind
-%.valgrind:
- cd tests && $(MAKE) $*.valgrind
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d0b1ca1f..1cdabf90 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,20 +1,7 @@
-INCLUDES = \
- -I$(top_srcdir)/gobject \
- $(PYTHON_INCLUDES) \
- $(GLIB_CFLAGS)
-
-EXTRA_DIST = \
- $(tests) \
- common.py \
- runtests.py \
- testmodule.py \
- test-floating.h \
- test-thread.h \
- test-unknown.h
noinst_LTLIBRARIES = testhelper.la
-linked_LIBS = testhelper.la
+testhelper_la_CFLAGS = -I$(top_srcdir)/gobject $(PYTHON_INCLUDES) $(GLIB_CFLAGS)
testhelper_la_LDFLAGS = -module -avoid-version
testhelper_la_LIBADD = $(GLIB_LIBS)
testhelper_la_SOURCES = \
@@ -23,49 +10,57 @@ testhelper_la_SOURCES = \
test-thread.c \
test-unknown.c
-tests = \
+# This is a hack to make sure a shared library is built
+testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES)
+ $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS)
+
+
+.la.so:
+ test -L $@ || $(LN_S) .libs/$@ $@
+
+
+all: $(LTLIBRARIES:.la=.so)
+
+
+EXTRA_DIST = \
+ runtests.py \
+ testmodule.py \
+ test-floating.h \
+ test-thread.h \
+ test-unknown.h \
+ \
+ test_gcancellable.py \
test_gicon.py \
test_gio.py \
test_gobject.py \
+ test_gresolver.py \
+ test_gsocket.py \
test_interface.py \
test_mainloop.py \
+ test_option.py \
test_properties.py \
test_signal.py \
+ test_source.py \
test_subprocess.py \
- test_unknown.py \
- test_source.py
+ test_thread.py
if ENABLE_INTROSPECTION
-tests += \
+EXTRA_DIST += \
test_everything.py \
test_gi.py \
test_overrides.py
endif
-# This is a hack to make sure a shared library is built
-testhelper.la: $(testhelper_la_OBJECTS) $(testhelper_la_DEPENDENCIES)
- $(LINK) -rpath $(pkgpyexecdir) $(testhelper_la_LDFLAGS) $(testhelper_la_OBJECTS) $(testhelper_la_LIBADD) $(LIBS)
-
-check-local: $(LTLIBRARIES:.la=.so)
- $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py $(top_builddir) $(tests)
-
-all: $(LTLIBRARIES:.la=.so)
clean-local:
rm -f $(LTLIBRARIES:.la=.so)
-.la.so:
- $(LN_S) .libs/$@ $@ || true
+
+check-local: $(LTLIBRARIES:.la=.so)
+ PYTHONPATH=$(top_builddir):$(top_builddir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} $(EXEC_NAME) $(PYTHON) $(srcdir)/runtests.py
check.gdb:
EXEC_NAME="gdb --args" $(MAKE) check
-%.gdb:
- EXEC_NAME="gdb --args" TEST_NAMES=$* $(MAKE) check
-
check.valgrind:
EXEC_NAME="valgrind" $(MAKE) check
-
-%.valgrind:
- EXEC_NAME="valgrind" TEST_NAMES=$* $(MAKE) check
-
diff --git a/tests/common.py b/tests/common.py
deleted file mode 100644
index 1fbeba49..00000000
--- a/tests/common.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import os
-import sys
-
-def importModules(buildDir):
- # Be very careful when you change this code, it's
- # fragile and the order is really significant
-
- sys.path.insert(0, buildDir)
- sys.path.insert(0, os.path.join(buildDir, 'glib'))
- sys.path.insert(0, os.path.join(buildDir, 'gobject'))
- sys.path.insert(0, os.path.join(buildDir, 'gio'))
-
- # testhelper
- sys.path.insert(0, os.path.join(buildDir, 'tests'))
- sys.argv.append('--g-fatal-warnings')
-
- testhelper = importModule('testhelper', '.')
- glib = importModule('glib', buildDir, 'glib')
- gobject = importModule('gobject', buildDir, 'gobject')
- gio = importModule('gio', buildDir, 'gio')
-
- globals().update(locals())
-
- os.environ['PYGTK_USE_GIL_STATE_API'] = ''
- gobject.threads_init()
-
-def importModule(module, directory, name=None):
- global isDistCheck
-
- origName = module
- if not name:
- name = module + '.la'
-
- try:
- obj = __import__(module, {}, {}, '')
- except ImportError, e:
- raise SystemExit('%s could not be imported: %s' % (origName, e))
-
- location = obj.__file__
-
- current = os.getcwd()
- expected = os.path.abspath(os.path.join(current, location))
- current = os.path.abspath(location)
- if current != expected:
- raise AssertionError('module %s imported from wrong location. Expected %s, got %s' % (
- module, expected, current))
- return obj
diff --git a/tests/runtests.py b/tests/runtests.py
index e6b483e4..eae684c8 100644
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -1,35 +1,24 @@
-#!/usr/bin/env python
-import glob
-import os
-import sys
-import unittest
-
-import common
-
-program = None
-if len(sys.argv) < 2:
- raise ValueError('Need at least 2 parameters: runtests.py <build-dir> '
- '<test-module-1> <test-module-2> ...')
+# -*- Mode: Python -*-
-buildDir = sys.argv[1]
-files = sys.argv[2:]
+import os
+import glob
-common.importModules(buildDir=buildDir)
+import unittest
-dir = os.path.split(os.path.abspath(__file__))[0]
-os.chdir(dir)
-def gettestnames():
- names = map(lambda x: x[:-3], files)
- return names
+# Load tests.
+if 'TEST_NAMES' in os.environ:
+ names = os.environ['TEST_NAMES'].split()
+else:
+ names = []
+ for filename in glob.iglob("test_*.py"):
+ names.append(filename[:-3])
-suite = unittest.TestSuite()
loader = unittest.TestLoader()
+suite = loader.loadTestsFromNames(names)
+
-for name in gettestnames():
- if program and program not in name:
- continue
- suite.addTest(loader.loadTestsFromName(name))
+# Run tests.
+runner = unittest.TextTestRunner(verbosity=2)
+runner.run(suite)
-testRunner = unittest.TextTestRunner(verbosity=2)
-testRunner.run(suite)
diff --git a/tests/test_gcancellable.py b/tests/test_gcancellable.py
index 7a0f94b9..f9115725 100644
--- a/tests/test_gcancellable.py
+++ b/tests/test_gcancellable.py
@@ -1,9 +1,9 @@
# -*- Mode: Python -*-
-import os
import unittest
-from common import gio, glib
+import glib
+import gio
class TestResolver(unittest.TestCase):
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 284b3624..08caf486 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -7,9 +7,6 @@ pygtk.require("2.0")
import unittest
from gi.repository import GObject
-import sys
-sys.path.insert(0, "../")
-
import gobject
from gi.repository import GIMarshallingTests
diff --git a/tests/test_gicon.py b/tests/test_gicon.py
index 5ce7ece7..b9af6ff0 100644
--- a/tests/test_gicon.py
+++ b/tests/test_gicon.py
@@ -3,7 +3,8 @@
import os
import unittest
-from common import gio, glib
+import glib
+import gio
class TestIcon(unittest.TestCase):
diff --git a/tests/test_gio.py b/tests/test_gio.py
index feafc700..7c8251ea 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -3,7 +3,8 @@
import os
import unittest
-from common import gio, glib
+import glib
+import gio
class TestFile(unittest.TestCase):
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index d91f3ad8..f3cdf293 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -2,7 +2,8 @@
import unittest
-from common import gobject, testhelper
+import gobject
+import testhelper
class TestGObjectAPI(unittest.TestCase):
diff --git a/tests/test_gresolver.py b/tests/test_gresolver.py
index 4303f0fd..ef8585c3 100644
--- a/tests/test_gresolver.py
+++ b/tests/test_gresolver.py
@@ -1,9 +1,9 @@
# -*- Mode: Python -*-
-import os
import unittest
-from common import gio, glib
+import glib
+import gio
class TestResolver(unittest.TestCase):
diff --git a/tests/test_gsocket.py b/tests/test_gsocket.py
index 16ff40f8..627f6fdd 100644
--- a/tests/test_gsocket.py
+++ b/tests/test_gsocket.py
@@ -3,7 +3,9 @@
import os
import unittest
-from common import gio, glib, gobject
+import glib
+import gobject
+import gio
class TestSocket(unittest.TestCase):
diff --git a/tests/test_interface.py b/tests/test_interface.py
index d9597917..fbc05860 100644
--- a/tests/test_interface.py
+++ b/tests/test_interface.py
@@ -1,6 +1,10 @@
+# -*- Mode: Python -*-
+
import unittest
-from common import gobject, testhelper
+import gobject
+import testhelper
+
GUnknown = gobject.type_from_name("TestUnknown")
Unknown = GUnknown.pytype
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py
index 95e5f789..4286d137 100644
--- a/tests/test_mainloop.py
+++ b/tests/test_mainloop.py
@@ -1,12 +1,12 @@
-#!/usr/bin/env python
+# -*- Mode: Python -*-
-import exceptions
import os
import sys
import select
import unittest
-from common import glib
+import glib
+
class TestMainLoop(unittest.TestCase):
def testExceptionHandling(self):
@@ -31,7 +31,7 @@ class TestMainLoop(unittest.TestCase):
os.close(pipe_w)
def excepthook(type, value, traceback):
- assert type is exceptions.Exception
+ assert type is Exception
assert value.args[0] == "deadbabe"
sys.excepthook = excepthook
@@ -48,6 +48,3 @@ class TestMainLoop(unittest.TestCase):
#
sys.excepthook = sys.__excepthook__
assert not got_exception
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/test_signal.py b/tests/test_signal.py
index 96e07312..075b03e5 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -4,7 +4,9 @@ import gc
import unittest
import sys
-from common import gobject, testhelper
+import gobject
+import testhelper
+
class C(gobject.GObject):
__gsignals__ = { 'my_signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
diff --git a/tests/test_source.py b/tests/test_source.py
index abe2f695..c4ea62ce 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -1,8 +1,8 @@
-#!/usr/bin/env python
+# -*- Mode: Python -*-
import unittest
-from common import glib
+import glib
class Idle(glib.Idle):
diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py
index 1522edb9..c90d1d69 100644
--- a/tests/test_subprocess.py
+++ b/tests/test_subprocess.py
@@ -3,7 +3,7 @@
import sys
import unittest
-from common import glib
+import glib
class TestProcess(unittest.TestCase):
@@ -22,6 +22,3 @@ class TestProcess(unittest.TestCase):
glib.child_watch_add(pid, self._child_watch_cb, 12345)
self.loop.run()
self.assertEqual(self.data, 12345)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/test_thread.py b/tests/test_thread.py
index 09ad0745..be746a4d 100644
--- a/tests/test_thread.py
+++ b/tests/test_thread.py
@@ -1,6 +1,9 @@
+# -*- Mode: Python -*-
+
import unittest
-from common import glib, testhelper
+import glib
+import testhelper
class TestThread(unittest.TestCase):
diff --git a/tests/test_unknown.py b/tests/test_unknown.py
index d65bb894..2a18eec7 100644
--- a/tests/test_unknown.py
+++ b/tests/test_unknown.py
@@ -1,7 +1,10 @@
+# -*- Mode: Python -*-
import unittest
-from common import gobject, testhelper
+import gobject
+import testhelper
+
TestInterface = gobject.GType.from_name('TestInterface')