[dia: 85/105] #19 review: Set test environment using dictionary.



commit 9c2016b1f6ff6068cdf9261943329e52b705b184
Author: Eduard Nicodei <eddnicodei gmail com>
Date:   Sat Jan 19 21:40:06 2019 +0000

    #19 review: Set test environment using dictionary.
    
      - This will help when custom_target will support custom environment
        https://github.com/mesonbuild/meson/issues/2723

 meson.build       |  7 ++++---
 tests/meson.build | 22 +++++++++++++---------
 2 files changed, 17 insertions(+), 12 deletions(-)
---
diff --git a/meson.build b/meson.build
index b88ae0d9..0055434e 100644
--- a/meson.build
+++ b/meson.build
@@ -85,8 +85,9 @@ subdir('sheets')
 subdir('shapes')
 subdir('tests')
 
-# This is a convenience target to create a way to run dia from
-# command line.
+# TODO: idealy this should use run_env from tests/
+# Unfortunately, neither run_target or custom_target support env
+# https://github.com/mesonbuild/meson/issues/2723
 custom_target('run_with_dia_env',
     command: [find_program('generate_run_with_dia_env.sh'),
               '@OUTPUT@',
@@ -95,7 +96,7 @@ custom_target('run_with_dia_env',
           ],
     output: 'run_with_dia_env',
     # Ensure we always generate this in the build directory.
-    build_by_default: true
+    build_by_default: true,
 )
 
 meson.add_install_script('meson-helpers/post-install.py', datadir)
diff --git a/tests/meson.build b/tests/meson.build
index 87306e79..3ba85184 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,14 +1,18 @@
 # Setup local environment to run dia.
-run_env = environment()
-run_env.set('DIA_BASE_PATH', meson.source_root())
-run_env.append('DIA_LIB_PATH',
-    join_paths(meson.build_root(), 'objects'),
-    join_paths(meson.build_root(), 'plug-ins'))
-run_env.set('DIA_SHAPE_PATH',  join_paths(meson.source_root(), 'shapes'))
-run_env.set('DIA_XSLT_PATH',   join_paths(meson.source_root(), 'plug-ins', 'xslt'))
-run_env.set('DIA_PYTHON_PATH', join_paths(meson.source_root(), 'plug-ins', 'python'))
-run_env.set('DIA_SHEET_PATH',  join_paths(meson.build_root(), 'sheets'))
+run_env_dict = {
+    'DIA_BASE_PATH'  : [meson.source_root()],
+    'DIA_LIB_PATH'   : [join_paths(meson.build_root(), 'objects'),
+                        join_paths(meson.build_root(), 'plug-ins')],
+    'DIA_SHAPE_PATH' : [join_paths(meson.source_root(), 'shapes')],
+    'DIA_XSLT_PATH'  : [join_paths(meson.source_root(), 'plug-ins', 'xslt')],
+    'DIA_PYTHON_PATH': [join_paths(meson.source_root(), 'plug-ins', 'python')],
+    'DIA_SHEET_PATH' : [join_paths(meson.build_root(), 'sheets')],
+}
 
+run_env = environment()
+foreach k, v : run_env_dict
+    run_env.set(k, v)
+endforeach
 # TODO: minimise code duplication.
 bb = executable(
     'boundingbox',


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