[gobject-introspection] tests: make scanner tests work with msvc + subprojects



commit 13e8c7ff80f9ff2dc77e9d0da4b7396182c63612
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Thu Dec 20 18:09:10 2018 +0100

    tests: make scanner tests work with msvc + subprojects
    
    Manually add all the subproject build directories to PATH for running
    the scanner tests.
    
    I'm wondering if meson shouldn't do this for us based on the dependency
    we pass to test(), but this will do for now.

 tests/meson.build                          | 18 ++++++++++++++++++
 tests/scanner/annotationparser/meson.build | 18 ++++++------------
 tests/scanner/meson.build                  | 24 ++++++++++--------------
 tests/scanner/test_docwriter.py            | 12 ++++++++++--
 4 files changed, 44 insertions(+), 28 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index c11151dc..23c0e919 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,3 +1,21 @@
+sub_build_root = join_paths(meson.build_root(), 'subprojects')
+test_env_common_path = []
+if glib_dep.type_name() == 'internal' and host_system == 'windows'
+  test_env_common_path += [
+    join_paths(sub_build_root, 'glib', 'glib'),
+    join_paths(sub_build_root, 'glib', 'gobject'),
+    join_paths(sub_build_root, 'glib', 'gio'),
+    join_paths(sub_build_root, 'glib', 'gmodule'),
+    join_paths(sub_build_root, 'proxy-libintl'),
+    join_paths(sub_build_root, 'zlib'),
+  ]
+endif
+if libffi_dep.type_name() == 'internal' and host_system == 'windows'
+  test_env_common_path += [join_paths(sub_build_root, 'libffi',  'src')]
+endif
+test_env_common_pypath = [meson.build_root()]
+
+
 test_regress_sources = files('scanner/regress.c')
 test_regress_headers = files('scanner/regress.h')
 test_marshalling_sources = files('gimarshallingtests.c')
diff --git a/tests/scanner/annotationparser/meson.build b/tests/scanner/annotationparser/meson.build
index 954dc28d..cce8c5c7 100644
--- a/tests/scanner/annotationparser/meson.build
+++ b/tests/scanner/annotationparser/meson.build
@@ -1,20 +1,14 @@
 annotationparser_test_env = environment()
-annotationparser_test_env.append('PYTHONPATH', join_paths(meson.current_build_dir(), '../../../'))
+annotationparser_test_env.prepend('PYTHONPATH', test_env_common_pypath)
+if test_env_common_path.length() > 0
+    annotationparser_test_env.prepend('PATH', test_env_common_path)
+endif
 
 annotationparser_test_files = [
   'test_patterns.py',
+  'test_parser.py',
 ]
 
-# FIXME: MSVC
-#   from giscanner._giscanner import SourceScanner as CSourceScanner
-#   ImportError: DLL load failed: The specified module could not be found.
-if cc.get_id() != 'msvc'
-  annotationparser_test_files += [
-    'test_parser.py',
-  ]
-endif
-
 foreach f : annotationparser_test_files
-  test(f, python, args: files(f), env: annotationparser_test_env)
+  test(f, python, args: files(f), env: annotationparser_test_env, depends: [giscanner_pymod])
 endforeach
-
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
index cc5ee530..62809169 100644
--- a/tests/scanner/meson.build
+++ b/tests/scanner/meson.build
@@ -1,24 +1,20 @@
-
 scanner_test_env = environment()
-scanner_test_env.append('PYTHONPATH', join_paths(meson.current_build_dir(), '../../'))
+scanner_test_env.prepend('PYTHONPATH', test_env_common_pypath)
+if test_env_common_path.length() > 0
+    scanner_test_env.prepend('PATH', test_env_common_path)
+endif
 
 scanner_test_files = [
   'test_shlibs.py',
+  'test_sourcescanner.py',
+  'test_transformer.py',
+  'test_xmlwriter.py',
+  'test_pkgconfig.py',
+  'test_docwriter.py',
 ]
 
-# FIXME: MSVC
-if cc.get_id() != 'msvc'
-  scanner_test_files += [
-    'test_sourcescanner.py',
-    'test_transformer.py',
-    'test_xmlwriter.py',
-    'test_pkgconfig.py',
-    'test_docwriter.py',
-    ]
-endif
-
 foreach f : scanner_test_files 
-  test(f, python, args: files(f), env: scanner_test_env)
+  test(f, python, args: files(f), env: scanner_test_env, depends: [giscanner_pymod])
 endforeach
 
 subdir('annotationparser')
diff --git a/tests/scanner/test_docwriter.py b/tests/scanner/test_docwriter.py
index 8b2d0fb0..3fb64171 100644
--- a/tests/scanner/test_docwriter.py
+++ b/tests/scanner/test_docwriter.py
@@ -1,9 +1,17 @@
 import unittest
 
-from giscanner.docwriter import DocWriter
-from giscanner.transformer import Transformer
+try:
+    import mako
+except ImportError:
+    HAS_MAKO = False
+else:
+    HAS_MAKO = True
+    mako
+    from giscanner.docwriter import DocWriter
+    from giscanner.transformer import Transformer
 
 
+@unittest.skipUnless(HAS_MAKO, "mako missing")
 class TestDocWriter(unittest.TestCase):
 
     def test_main(self):


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