gnome-python r639 - in trunk: . gnomevfs tests



Author: gjc
Date: Thu Dec 25 18:40:04 2008
New Revision: 639
URL: http://svn.gnome.org/viewvc/gnome-python?rev=639&view=rev

Log:
Run unit tests in the WAF build system

Modified:
   trunk/ChangeLog
   trunk/gnomevfs/wscript
   trunk/tests/common.py
   trunk/tests/runtests.py
   trunk/wscript

Modified: trunk/gnomevfs/wscript
==============================================================================
--- trunk/gnomevfs/wscript	(original)
+++ trunk/gnomevfs/wscript	Thu Dec 25 18:40:04 2008
@@ -59,6 +59,7 @@
 
     if 'gnomevfs.module' in bld.env()['MODULES_TO_BUILD']:
         pyembed = bld.create_obj('cc', 'shlib', 'pyembed')
+        pyembed.mac_bundle = True
         pyembed.source = 'gnome-vfs-python-method.c'
         pyembed.target = 'pythonmethod'
         pyembed.uselib = 'GNOMEVFSMODULE'

Modified: trunk/tests/common.py
==============================================================================
--- trunk/tests/common.py	(original)
+++ trunk/tests/common.py	Thu Dec 25 18:40:04 2008
@@ -1,18 +1,45 @@
 import os
 import sys
 
-if not os.environ.has_key('DIST_CHECK'):
-    sys.path = ['..', '../gnomevfs', '../gnomecanvas'] + sys.path
+#if not os.environ.has_key('DIST_CHECK'):
+#    sys.path = ['..', '../gnomevfs', '../gnomecanvas'] + sys.path
 
-import ltihooks
-ltihooks.install()
 
-import bonobo
-import gnomevfs
-import bonobo.ui
-import gconf
-import gnome
-import gnome.ui
-import gnomecanvas
+modules = [
+    "bonobo",
+    "gnomevfs",
+    "bonobo.ui",
+    "bonobo",
+    "gconf",
+    "gnome",
+    "gnome.ui",
+    "gnomecanvas",
+]
+
+def run_import_tests(builddir, no_import_hooks):
+    if not no_import_hooks:
+        import ltihooks
+        ltihooks.install()
+
+    for item in modules:
+        if isinstance(item, tuple):
+            module, dirname = item
+        else:
+            module = item
+            dirname = item
+        #sys.path.insert(0, os.path.join(builddir, dirname))
+        print "Trying to import module %s... " % (module,),
+        try:
+            mod = __import__(module) # try to import the module to catch undefined symbols
+        except ImportError, ex:
+            if ex.args[0].startswith("No module named"):
+                print "not found"
+            else:
+                raise
+        else:
+            print "ok."
+            globals()[module] = mod
+
+    if not no_import_hooks:
+        ltihooks.uninstall()
 
-ltihooks.uninstall()

Modified: trunk/tests/runtests.py
==============================================================================
--- trunk/tests/runtests.py	(original)
+++ trunk/tests/runtests.py	Thu Dec 25 18:40:04 2008
@@ -6,6 +6,17 @@
 
 #SKIP_FILES = ['common', 'runtests']
 
+if sys.argv > 1:
+    builddir = sys.argv[1]
+    no_import_hooks = True
+else:
+    builddir = '..'
+    no_import_hooks = False
+
+import common
+common.run_import_tests(builddir, no_import_hooks)
+
+
 dir = os.path.split(os.path.abspath(__file__))[0]
 os.chdir(dir)
 

Modified: trunk/wscript
==============================================================================
--- trunk/wscript	(original)
+++ trunk/wscript	Thu Dec 25 18:40:04 2008
@@ -37,6 +37,10 @@
     conf.check_tool('compiler_cc')
     conf.check_tool('gnome')
     conf.check_tool('python')
+
+    if sys.platform == 'darwin':
+        conf.check_tool('osx')
+
     conf.check_python_version((2,4))
     conf.check_python_headers()
     conf.define('VERSION', VERSION)
@@ -128,3 +132,29 @@
     bld.add_subdirs('gnomevfs')
     bld.add_subdirs('docs/gnomevfs')
 
+
+def shutdown():
+    env = Params.g_build.env_of_name('default')
+
+    if Params.g_commands['check']:
+        _run_tests(env)
+
+
+def _run_tests(env):
+    import pproc as subprocess
+    import shutil
+    builddir = os.path.join(blddir, env.variant())
+    # copy the __init__.py files
+    for subdir in ["bonobo", "gnome", "gnomevfs"]:
+        src = os.path.join(subdir, "__init__.py")
+        dst = os.path.join(builddir, subdir)
+        shutil.copy(src, dst)
+    os_env = dict(os.environ)
+    if 'PYTHONPATH' in os_env:
+        os_env['PYTHONPATH'] = os.pathsep.join([builddir, os_env['PYTHONPATH']])
+    else:
+        os_env['PYTHONPATH'] = builddir
+    cmd = [env['PYTHON'], os.path.join('tests', 'runtests.py'), builddir]
+    retval = subprocess.Popen(cmd, env=os_env).wait()
+    if retval:
+        sys.exit(retval)



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