[tracker/sam/tracker-sandbox-shared: 3/3] utils/trackertestutils: Make it usable by other projects



commit 3c277c946a50dd600820e7adf74e0e9394dd8966
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Sep 28 14:44:07 2019 +0200

    utils/trackertestutils: Make it usable by other projects
    
    This command improves the tracker-testutils-2.0 pkg-config package,
    by adding a `command=` variable.
    
    The idea is that projects using Tracker can use this as a way to
    sandbox their test suites from the user's real Tracker data.
    
    In your meson.build file you would do something like this to locate
    the script and run your test.
    
        python3 = find_program('python3')
        trackertestutils = dependency('tracker-testutils-2.0')
    
        tracker_sandbox_command = find_program(trackertestutils.get_pkgconfig_variable('command'))
    
        test('myapptest', tracker_sandbox_command,
          args: ['--index-tmpdir', my_app_test_executable])
    
    This would ensure that XDG_CACHE_HOME and XDG_DATA_HOME point to a
    temporary directory, separate from any real Tracker index data that the
    current user might have inside their XDG cache & data directories.

 meson_options.txt                  |  4 ++--
 utils/trackertestutils/meson.build | 17 ++++++++++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/meson_options.txt b/meson_options.txt
index d4b3b2a81..509b3479f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -23,6 +23,6 @@ option('dbus_services', type: 'string', value: '',
 option('systemd_user_services', type: 'string', value: 'yes',
        description: 'Directory to install systemd user .service files (or "yes" for default directory, "no" 
to disable installation)')
 option('test_utils', type: 'boolean', value: true,
-       description: 'Whether to install the tracker test utils')
+       description: 'Whether to install the trackertestutils Python package')
 option('test_utils_dir', type: 'string', value: '',
-       description: 'Directory to install tracker test utils (or empty to use the default)')
+       description: 'Directory to install trackertestutils Python package (or empty to use the default)')
diff --git a/utils/trackertestutils/meson.build b/utils/trackertestutils/meson.build
index 78c6fa59d..c94aa507c 100644
--- a/utils/trackertestutils/meson.build
+++ b/utils/trackertestutils/meson.build
@@ -2,6 +2,7 @@ pkg = import('pkgconfig')
 
 sources = [
   '__init__.py',
+  '__main__.py',
   'dbusdaemon.py',
   'dconf.py',
   'helpers.py',
@@ -15,16 +16,26 @@ if get_option('test_utils')
   if testutils_dir == ''
     arch_independent_libdir = \
       get_option('prefix') / 'lib' / 'tracker-' + tracker_api_version
-    testutils_dir = join_paths(arch_independent_libdir, 'trackertestutils')
+    testutils_dir = join_paths(arch_independent_libdir)
   endif
 
-  install_data(sources, install_dir: testutils_dir)
+  install_data(sources, install_dir: testutils_dir / 'trackertestutils')
+
+  script_conf = configuration_data()
+  script_conf.set('prefix', get_option('prefix'))
+  script_conf.set('testutils_dir', testutils_dir)
+  configure_file(
+    input: 'tracker-sandbox.in',
+    output: 'tracker-sandbox',
+    configuration: script_conf,
+    install_dir: testutils_dir / 'trackertestutils')
 
   pkg.generate(
     name: 'tracker-testutils-' + tracker_api_version,
     description: 'tracker test utilities',
     variables: [
-      'python_path=' + testutils_dir
+      'python_path=' + testutils_dir,
+      'command=' + testutils_dir / 'trackertestutils' / 'tracker-sandbox',
     ]
   )
 endif


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