[gnome-music/wip/jfelder/build-no-net: 1/2] build: Add network_tests build option



commit 8b69790d858589c19eb2e7ccd8ea5da28ed4e8da
Author: Jean Felder <jfelder src gnome org>
Date:   Fri May 1 00:24:22 2020 +0200

    build: Add network_tests build option
    
    This allows disabling network for tests on build systems that do not
    allow network during unit tests.
    
    Configuring with -Dnetwork_tests=false will disable appstream validation
    by using the --nonet option.

 data/meson.build  | 10 +++++-----
 meson_options.txt |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 25ff1e10..3167f420 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -62,11 +62,11 @@ i18n.merge_file(
 # Validating the appdata file
 appstream_util = find_program('appstream-util', required: false)
 if appstream_util.found()
-  test (
-    'Validate appdata file',
-    appstream_util,
-    args: ['validate-relax', join_paths(meson.current_build_dir (), APPLICATION_ID + '.appdata.xml')]
-  )
+  validate_args = ['validate-relax', join_paths(meson.current_build_dir (), APPLICATION_ID + '.appdata.xml')]
+  if not get_option('network_tests')
+    validate_args += '--nonet'
+  endif
+  test('Validate appdata file', appstream_util, args: validate_args)
 endif
 
 # Installing the default icon
diff --git a/meson_options.txt b/meson_options.txt
index a9e396dd..53097192 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,5 @@ option(
   ],
   value: 'default'
 )
+
+option('network_tests', type: 'boolean', value: true, description: 'Allow networking in unit-tests')


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