[Spice-devel] [PATCH v7 16/20] build: Use a convenience library for tests

Victor Toso victortoso at redhat.com
Mon Sep 16 10:20:59 UTC 2019


From: Frediano Ziglio <fziglio at redhat.com>

Instead of linking all object inside spice-client-glib build a library
from these object and link to each test.
This will allow to override some object file for mocking purposes.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tests/meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/meson.build b/tests/meson.build
index 39eac9c..57bd2cc 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -21,12 +21,18 @@ if spice_gtk_has_polkit
   ]
 endif
 
+# create a static library from a shared one extracting all objects
+# this allows to rewrite part of it if necessary for mocking
+test_lib = \
+  static_library('test-lib',
+                 objects : spice_client_glib_lib.extract_all_objects())
+
 foreach src : tests_sources
   name = 'test- at 0@'.format(src).split('.')[0]
   exe = executable(name,
                    sources : src,
                    c_args : '-DTESTDIR="@0@"'.format(meson.current_build_dir()),
-                   objects : spice_client_glib_lib.extract_all_objects(),
+                   link_with : test_lib,
                    dependencies : spice_client_glib_dep)
   if not name.contains('mock-acl-helper')
     test(name, exe)
-- 
2.21.0



More information about the Spice-devel mailing list