[gnome-software] Allow running self tests without gnome-software installed



commit 0dd48567caf8e12c72076aacdd4b0560915fa7f1
Author: Richard Hughes <richard hughsie com>
Date:   Wed Oct 18 18:21:12 2017 +0100

    Allow running self tests without gnome-software installed

 data/meson.build                     |    2 +-
 lib/meson.build                      |    3 ++-
 meson.build                          |   10 +++++++++-
 plugins/core/meson.build             |    6 ++++--
 plugins/dpkg/meson.build             |    6 ++++--
 plugins/dummy/meson.build            |    6 ++++--
 plugins/epiphany/meson.build         |    6 ++++--
 plugins/flatpak/meson.build          |    6 ++++--
 plugins/fwupd/meson.build            |    6 ++++--
 plugins/modalias/meson.build         |    6 ++++--
 plugins/packagekit/meson.build       |    6 ++++--
 plugins/repos/meson.build            |    6 ++++--
 plugins/shell-extensions/meson.build |    6 ++++--
 plugins/snap/meson.build             |    6 ++++--
 src/meson.build                      |    3 ++-
 15 files changed, 58 insertions(+), 26 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 4be6a3d..b260411 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -2,7 +2,7 @@ subdir('appdata')
 subdir('icons')
 subdir('assets')
 
-compiled = gnome.compile_schemas()
+compiled_schemas = gnome.compile_schemas()
 install_data('org.gnome.software.gschema.xml',
              install_dir : 'share/glib-2.0/schemas')
 
diff --git a/lib/meson.build b/lib/meson.build
index 92c92ac..8f0b696 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -125,6 +125,7 @@ if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), '..', 'data') + '"']
   e = executable(
     'gs-self-test',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -146,5 +147,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs
   )
-  test('gs-self-test-lib', e)
+  test('gs-self-test-lib', e, env: test_env)
 endif
diff --git a/meson.build b/meson.build
index fe587b9..ea5a03d 100644
--- a/meson.build
+++ b/meson.build
@@ -204,11 +204,19 @@ configure_file(
 add_project_arguments('-DI_KNOW_THE_GNOME_SOFTWARE_API_IS_SUBJECT_TO_CHANGE',
                       language : 'c')
 
+test_env = [
+  'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+  'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+  'GSETTINGS_SCHEMA_DIR=@0@/data/'.format(meson.build_root()),
+  'GSETTINGS_BACKEND=memory',
+  'MALLOC_CHECK_=2',
+]
+
+subdir('data')
 subdir('lib')
 subdir('plugins')
 subdir('src')
 subdir('po')
-subdir('data')
 subdir('doc')
 
 if meson.version().version_compare('<0.41.0')
diff --git a/plugins/core/meson.build b/plugins/core/meson.build
index 4fb2870..d73572c 100644
--- a/plugins/core/meson.build
+++ b/plugins/core/meson.build
@@ -195,7 +195,9 @@ shared_module(
 if get_option('enable-tests')
   cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"']
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
-  e = executable('gs-self-test-core',
+  e = executable(
+    'gs-self-test-core',
+    compiled_schemas,
     sources : [
       'gs-self-test.c',
       'gs-appstream.c'
@@ -212,5 +214,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-core', e)
+  test('gs-self-test-core', e, env: test_env)
 endif
diff --git a/plugins/dpkg/meson.build b/plugins/dpkg/meson.build
index 8f02571..e211882 100644
--- a/plugins/dpkg/meson.build
+++ b/plugins/dpkg/meson.build
@@ -16,7 +16,9 @@ shared_module(
 if get_option('enable-tests')
   cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"']
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
-  e = executable('gs-self-test-dpkg',
+  e = executable(
+    'gs-self-test-dpkg',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -32,5 +34,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-dpkg', e)
+  test('gs-self-test-dpkg', e, env: test_env)
 endif
diff --git a/plugins/dummy/meson.build b/plugins/dummy/meson.build
index 2bc0abc..e7b6602 100644
--- a/plugins/dummy/meson.build
+++ b/plugins/dummy/meson.build
@@ -16,7 +16,9 @@ shared_module(
 )
 
 if get_option('enable-tests')
-  e = executable('gs-self-test-dummy',
+  e = executable(
+    'gs-self-test-dummy',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -32,5 +34,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-dummy', e)
+  test('gs-self-test-dummy', e, env: test_env)
 endif
diff --git a/plugins/epiphany/meson.build b/plugins/epiphany/meson.build
index d793e60..4d535a1 100644
--- a/plugins/epiphany/meson.build
+++ b/plugins/epiphany/meson.build
@@ -27,7 +27,9 @@ i18n.merge_file(
 
 if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), '..', '..', 'data') + '"']
-  e = executable('gs-self-test-epiphany',
+  e = executable(
+    'gs-self-test-epiphany',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -43,5 +45,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-epiphany', e)
+  test('gs-self-test-epiphany', e, env: test_env)
 endif
diff --git a/plugins/flatpak/meson.build b/plugins/flatpak/meson.build
index e7b7f95..8fbd194 100644
--- a/plugins/flatpak/meson.build
+++ b/plugins/flatpak/meson.build
@@ -36,7 +36,9 @@ if get_option('enable-tests')
   cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"']
   cargs += ['-DLOCALPLUGINDIR_CORE="' + meson.current_build_dir() + '/../core"']
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_build_dir(), 'tests') + '"']
-  e = executable('gs-self-test-flatpak',
+  e = executable(
+    'gs-self-test-flatpak',
+    compiled_schemas,
     sources : [
       'gs-flatpak-app.c',
       'gs-self-test.c'
@@ -54,5 +56,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-flatpak', e, timeout : 120)
+  test('gs-self-test-flatpak', e, env: test_env, timeout : 120)
 endif
diff --git a/plugins/fwupd/meson.build b/plugins/fwupd/meson.build
index 00c6f73..9cae7db 100644
--- a/plugins/fwupd/meson.build
+++ b/plugins/fwupd/meson.build
@@ -29,7 +29,9 @@ i18n.merge_file(
 
 if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
-  e = executable('gs-self-test-fwupd',
+  e = executable(
+    'gs-self-test-fwupd',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -45,5 +47,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-fwupd', e)
+  test('gs-self-test-fwupd', e, env: test_env)
 endif
diff --git a/plugins/modalias/meson.build b/plugins/modalias/meson.build
index 50a6687..dcefc7c 100644
--- a/plugins/modalias/meson.build
+++ b/plugins/modalias/meson.build
@@ -17,7 +17,9 @@ sources : 'gs-plugin-modalias.c',
 )
 
 if get_option('enable-tests')
-  e = executable('gs-self-test-modalias',
+  e = executable(
+    'gs-self-test-modalias',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -33,5 +35,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-modalias', e)
+  test('gs-self-test-modalias', e, env: test_env)
 endif
diff --git a/plugins/packagekit/meson.build b/plugins/packagekit/meson.build
index f9e57ab..ac049f2 100644
--- a/plugins/packagekit/meson.build
+++ b/plugins/packagekit/meson.build
@@ -138,7 +138,9 @@ sources : 'gs-plugin-packagekit-proxy.c',
 
 if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
-  e = executable('gs-self-test-packagekit',
+  e = executable(
+    'gs-self-test-packagekit',
+    compiled_schemas,
     sources : [
       'gs-markdown.c',
       'gs-self-test.c'
@@ -155,5 +157,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-packagekit', e)
+  test('gs-self-test-packagekit', e, env: test_env)
 endif
diff --git a/plugins/repos/meson.build b/plugins/repos/meson.build
index d35e27b..59889cf 100644
--- a/plugins/repos/meson.build
+++ b/plugins/repos/meson.build
@@ -16,7 +16,9 @@ shared_module(
 
 if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), 'tests') + '"']
-  e = executable('gs-self-test-repos',
+  e = executable(
+    'gs-self-test-repos',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -32,5 +34,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-repos', e)
+  test('gs-self-test-repos', e, env: test_env)
 endif
diff --git a/plugins/shell-extensions/meson.build b/plugins/shell-extensions/meson.build
index f2849e4..e35f310 100644
--- a/plugins/shell-extensions/meson.build
+++ b/plugins/shell-extensions/meson.build
@@ -15,7 +15,9 @@ sources : 'gs-plugin-shell-extensions.c',
 )
 
 if get_option('enable-tests')
-  e = executable('gs-self-test-shell-extensions',
+  e = executable(
+    'gs-self-test-shell-extensions',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -31,5 +33,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-shell-extensions', e)
+  test('gs-self-test-shell-extensions', e, env: test_env)
 endif
diff --git a/plugins/snap/meson.build b/plugins/snap/meson.build
index 9d7cc80..c44d13e 100644
--- a/plugins/snap/meson.build
+++ b/plugins/snap/meson.build
@@ -28,7 +28,9 @@ i18n.merge_file(
 if get_option('enable-tests')
   cargs += ['-DLOCALPLUGINDIR="' + meson.current_build_dir() + '"']
   cargs += ['-DLOCALPLUGINDIR_CORE="' + meson.current_build_dir() + '/../core"']
-  e = executable('gs-self-test-snap',
+  e = executable(
+    'gs-self-test-snap',
+    compiled_schemas,
     sources : [
       'gs-self-test.c'
     ],
@@ -45,5 +47,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs,
   )
-  test('gs-self-test-snap', e)
+  test('gs-self-test-snap', e, env: test_env)
 endif
diff --git a/src/meson.build b/src/meson.build
index a89ff31..bf18924 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -274,6 +274,7 @@ if get_option('enable-tests')
   cargs += ['-DTESTDATADIR="' + join_paths(meson.current_source_dir(), '..', 'data') + '"']
   e = executable(
     'gs-self-test-src',
+    compiled_schemas,
     sources : [
       'gs-css.c',
       'gs-common.c',
@@ -298,5 +299,5 @@ if get_option('enable-tests')
     ],
     c_args : cargs
   )
-  test('gs-self-test-src', e)
+  test('gs-self-test-src', e, env: test_env)
 endif


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