[dia: 86/105] #19 cleanup: Remove duplication in tests/meson.build.



commit af35ae0c75aeadf652f409883d4dfd3d64f43c7e
Author: Eduard Nicodei <eddnicodei gmail com>
Date:   Sat Jan 19 21:42:05 2019 +0000

    #19 cleanup: Remove duplication in tests/meson.build.

 tests/meson.build | 59 +++++++++++++++++++------------------------------------
 1 file changed, 20 insertions(+), 39 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index 3ba85184..d7320392 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -13,51 +13,34 @@ run_env = environment()
 foreach k, v : run_env_dict
     run_env.set(k, v)
 endforeach
-# TODO: minimise code duplication.
-bb = executable(
-    'boundingbox',
-    'test-boundingbox.c',
-    dependencies: [libgtk_dep, libxml_dep, libm_dep],
-    link_with: [libdia],
-    link_args: dia_link_args,
-    include_directories: [configuration_inc, libdia_inc],
-)
-objs = executable(
-    'objects',
-    'test-objects.c',
-    dependencies: [libgtk_dep, libxml_dep, libm_dep],
-    link_with: [libdia],
-    link_args: dia_link_args,
-    include_directories: [configuration_inc, libdia_inc],
-)
 
 # Otherwise Windows won't be able to find libdia.dll in build directory.
 if host_machine.system() == 'windows'
     run_env.append('PATH', join_paths(meson.build_root(), 'lib'))
 endif
 
-tsvg = executable(
-    'testsvg',
-    'test-svg.c',
-    dependencies: [libgtk_dep, libxml_dep, libm_dep],
-    link_with: [libdia],
-    link_args: dia_link_args,
-    include_directories: [configuration_inc, libdia_inc],
-)
-sizeof = executable(
-    'sizeof',
-    'test-sizeof.c',
-    dependencies: [libgtk_dep, libxml_dep, libm_dep],
-    link_with: [libdia],
-    link_args: dia_link_args,
-    include_directories: [configuration_inc, libdia_inc],
-)
+test_exes = []
+foreach t : ['boundingbox', 'objects', 'svg', 'sizeof']
+    test_exes += [
+        executable(
+            'test-' + t,
+            'test-' + t + '.c',
+            dependencies: [libgtk_dep, libxml_dep, libm_dep],
+            link_with: [libdia],
+            link_args: dia_link_args,
+            include_directories: [configuration_inc, libdia_inc],
+        )
+    ]
+endforeach
 
-# Not really a test, but just a helper program.
-run_target('sizeof', command: [sizeof])
+# Unfortunately dictionaries can only contain literal strings.
+# As such we have to use indeces instead.
+test('boundinbox', test_exes[0])
+test('objects', test_exes[1], args: [join_paths(meson.build_root(), 'objects')])
+test('testsvg', test_exes[2])
 
-test('boundingbox', bb)
-test('objects', objs, args: [join_paths(meson.build_root(), 'objects')])
+# Not really a test, but just a helper program.
+run_target('sizeof', command: [test_exes[3]])
 
 xmllint_test = find_program('xmllint_test.sh')
 render_test_dia = files(join_paths('..', 'samples', 'render-test.dia'))[0]
@@ -74,6 +57,4 @@ test('xmllint',
     env: run_env,
 )
 
-test('testsvg', tsvg)
-
 subdir('exports')


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