[spice-gtk,v5,14/18] build: Use a convenience library for tests

Submitted by Frediano Ziglio on Aug. 28, 2019, 2:14 p.m.

Details

Message ID 20190828141421.18902-15-fziglio@redhat.com
State Superseded
Headers show
Series "added feature of sharing CD image" ( rev: 7 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Aug. 28, 2019, 2:14 p.m.
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@redhat.com>
---
 tests/meson.build | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/tests/meson.build b/tests/meson.build
index 39eac9c9..57bd2cc5 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-@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)