[gtk/testsuites-reorg: 2/2] WIP: Reorganise the testsuites



commit f49ef766a82423c6ce3e2697e211523e4391b807
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Feb 13 17:01:24 2020 +0000

    WIP: Reorganise the testsuites
    
     - Use a dictionary instead of opaque arrays of arrays
     - Use the environment() object

 testsuite/gtk/meson.build | 322 ++++++++++++++++++++++++++--------------------
 1 file changed, 185 insertions(+), 137 deletions(-)
---
diff --git a/testsuite/gtk/meson.build b/testsuite/gtk/meson.build
index 333f4347cb..bdf63a1fe5 100644
--- a/testsuite/gtk/meson.build
+++ b/testsuite/gtk/meson.build
@@ -7,111 +7,161 @@ if cc.get_id() != 'msvc'
   gtk_tests_export_dynamic_ldflag = ['-Wl,--export-dynamic']
 endif
 
+is_debug = get_option('buildtype').startswith('debug')
+
+# An array of dictionaries with the following keys:
+#
+#  - name: the name of the test; also used to generate the
+#          name of the source file with the test (MANDATORY)
+#  - sources: an array of additional source files (OPTIONAL)
+#  - cflags: an array of additonal compiler flags (OPTIONAL)
+#  - ldflags: an array of additional linker flags (OPTIONAL)
+#  - suites: an array of additional suite names (OPTIONAL)
+#  - xfail: a boolean value indicating whether the test is
+#           expected to fail (OPTIONAL)
+#
 tests = [
-  ['accel'],
-  ['accessible'],
-  ['action'],
-  ['adjustment'],
-  ['bitmask', ['../../gtk/gtkallocatedbitmask.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
-  ['builder', [], [], gtk_tests_export_dynamic_ldflag],
-  ['builderparser'],
-  ['cellarea'],
-  ['check-icon-names'],
-  ['constraint-solver', [
+  { 'name': 'accel' },
+  { 'name': 'accessible' },
+  { 'name': 'action' },
+  { 'name': 'adjustment' },
+  { 'name': 'bitmask',
+    'sources': ['../../gtk/gtkallocatedbitmask.c'],
+    'cflags': ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG'],
+    'suites': ['internals'],
+  },
+  { 'name': 'builder',
+    'ldflags': gtk_tests_export_dynamic_ldflag,
+  },
+  { 'name': 'builderparser' },
+  { 'name': 'cellarea' },
+  { 'name': 'check-icon-names' },
+  { 'name': 'constraint-solver',
+    'sources': [
       '../../gtk/gtkconstraintsolver.c',
       '../../gtk/gtkconstraintexpression.c',
-    ], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']
-  ],
-  ['cssprovider'],
-  ['rbtree-crash', ['../../gtk/gtkrbtree.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
-  ['defaultvalue'],
-  ['entry'],
-  ['filterlistmodel'],
-  ['flattenlistmodel'],
-  ['floating'],
-  ['focus'],
-  ['gestures'],
-  ['grid'],
-  ['grid-layout'],
-  ['icontheme'],
-  ['keyhash', ['../../gtk/gtkkeyhash.c', gtkresources, '../../gtk/gtkprivate.c'], gtk_cargs],
-  ['listbox'],
-  ['main'],
-  ['maplistmodel'],
-  ['notify'],
-  ['no-gtk-init'],
-  ['object'],
-  ['objects-finalize'],
-  ['papersize'],
-  ['popover'],
-  ['propertylookuplistmodel', ['../../gtk/gtkpropertylookuplistmodel.c'], ['-DGTK_COMPILATION', 
'-UG_ENABLE_DEBUG']],
-  ['rbtree', ['../../gtk/gtktreerbtree.c'], ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG']],
-  ['recentmanager'],
-  ['regression-tests'],
-  ['scrolledwindow'],
-  ['searchbar'],
-  ['singleselection'],
-  ['slicelistmodel'],
-  ['sortlistmodel'],
-  ['spinbutton'],
-  ['templates'],
-  ['textbuffer'],
-  ['textiter'],
-  ['theme-validate'],
-  ['treelistmodel'],
-  ['treemodel', ['treemodel.c', 'liststore.c', 'treestore.c', 'filtermodel.c',
-                 'modelrefcount.c', 'sortmodel.c', 'gtktreemodelrefcount.c']],
-  ['treepath'],
-  ['treeview'],
-  ['typename'],
-  ['window'],
-  ['displayclose'],
-  ['revealer-size'],
-  ['widgetorder'],
-]
-
-# Tests that are expected to fail
-xfail = [
+    ],
+    'cflags': ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG'],
+    'suites': ['internals'],
+  },
+  { 'name': 'cssprovider' },
+  { 'name': 'rbtree-crash',
+    'sources': ['../../gtk/gtkrbtree.c'],
+    'cflags': ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG'],
+    'suites': ['internals'],
+  },
+  { 'name': 'defaultvalue' },
+  { 'name': 'entry' },
+  { 'name': 'filterlistmodel' },
+  { 'name': 'flattenlistmodel' },
+  { 'name': 'floating' },
+  { 'name': 'focus' },
+  { 'name': 'gestures' },
+  { 'name': 'grid' },
+  { 'name': 'grid-layout' },
+  { 'name': 'icontheme' },
+  { 'name': 'keyhash',
+    'sources': [
+      '../../gtk/gtkkeyhash.c',
+      gtkresources,
+      '../../gtk/gtkprivate.c',
+    ],
+    'cflags': gtk_cargs,
+    'suites': ['internals'],
+  },
+  { 'name': 'listbox' },
+  { 'name': 'main' },
+  { 'name': 'maplistmodel' },
+  { 'name': 'notify' },
+  { 'name': 'no-gtk-init' },
+  { 'name': 'object' },
+  { 'name': 'objects-finalize' },
+  { 'name': 'papersize' },
+  { 'name': 'popover' },
+  { 'name': 'propertylookuplistmodel',
+    'sources': ['../../gtk/gtkpropertylookuplistmodel.c'],
+    'cflags': ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG'],
+    'suites': ['internals'],
+  },
+  { 'name': 'rbtree',
+    'sources': ['../../gtk/gtktreerbtree.c'],
+    'cflags': ['-DGTK_COMPILATION', '-UG_ENABLE_DEBUG'],
+    'suites': ['internals'],
+  },
+  { 'name': 'recentmanager' },
+  { 'name': 'regression-tests' },
+  { 'name': 'scrolledwindow' },
+  { 'name': 'searchbar' },
+  { 'name': 'singleselection' },
+  { 'name': 'slicelistmodel' },
+  { 'name': 'sortlistmodel' },
+  { 'name': 'spinbutton' },
+  { 'name': 'templates' },
+  { 'name': 'textbuffer' },
+  { 'name': 'textiter' },
+  { 'name': 'theme-validate' },
+  { 'name': 'treelistmodel' },
+  { 'name': 'treemodel',
+    'sources': [
+      'treemodel.c',
+      'liststore.c',
+      'treestore.c',
+      'filtermodel.c',
+      'modelrefcount.c',
+      'sortmodel.c',
+      'gtktreemodelrefcount.c',
+    ],
+  },
+  { 'name': 'treepath' },
+  { 'name': 'treeview' },
+  { 'name': 'typename' },
+  { 'name': 'window' },
+  { 'name': 'displayclose' },
+  { 'name': 'revealer-size' },
+  { 'name': 'widgetorder' },
 ]
 
-is_debug = get_option('buildtype').startswith('debug')
-
 test_cargs = []
 
 if os_unix
-  # tests += [['defaultvalue']]  # disabled in Makefile.am as well
   test_cargs += ['-DHAVE_UNIX_PRINT_WIDGETS']
 endif
 
+test_env = environment()
+test_env.set('GIO_USE_VOLUME_MONITOR', 'unix')
+test_env.set('GSETTINGS_BACKEND', 'memory')
+test_env.set('GDK_DEBUG', 'default-settings')
+test_env.set('GTK_CSD', '1')
+test_env.set('G_ENABLE_DIAGNOSTIC', '0')
+test_env.set('GSK_RENDERER', 'cairo')
+test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('GSETTINGS_SCHEMA_DIR', gtk_schema_build_dir)
+
 foreach t : tests
-  test_name = t.get(0)
-  test_srcs = ['@0@.c'.format(test_name)] + t.get(1, [])
-  test_extra_cargs = t.get(2, [])
-  test_extra_ldflags = t.get(3, [])
-
-  test_exe = executable(test_name, test_srcs,
-    c_args : test_cargs + test_extra_cargs,
-    link_args : test_extra_ldflags,
-    dependencies : libgtk_dep,
-    install: get_option('install-tests'),
-    install_dir: testexecdir)
+  test_name = t['name']
+
+  test_srcs = ['@0@.c'.format(test_name)] + t.get('sources', [])
+  test_extra_cargs = t.get('cflags', [])
+  test_extra_ldflags = t.get('ldflags', [])
+  test_extra_suites = t.get('suites', [])
+  test_xfail = t.get('xfail', false)
 
-  expect_fail = xfail.contains(test_name)
+  test_exe = executable(test_name,
+    test_srcs,
+    c_args: test_cargs + test_extra_cargs,
+    link_args: test_extra_ldflags,
+    dependencies: libgtk_dep,
+    install: get_option('install-tests'),
+    install_dir: testexecdir,
+  )
 
   test(test_name, test_exe,
-       args: [ '--tap', '-k' ],
-       env: [ 'GIO_USE_VOLUME_MONITOR=unix',
-              'GSETTINGS_BACKEND=memory',
-              'GDK_DEBUG=default-settings',
-              'GTK_CSD=1',
-              'G_ENABLE_DIAGNOSTIC=0',
-              'GSK_RENDERER=cairo',
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
-              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
-            ],
-       suite: 'gtk',
-       should_fail: expect_fail,
+    args: [ '--tap', '-k' ],
+    protocol: 'tap',
+    env: test_env,
+    suite: ['gtk'] + test_extra_suites,
+    should_fail: test_xfail,
   )
 endforeach
 
@@ -125,15 +175,8 @@ if add_languages('cpp', required: false)
                         install_dir: testexecdir)
   test('c++ keywords', test_exe,
        args: [ '--tap', '-k' ],
-       env: [ 'GIO_USE_VOLUME_MONITOR=unix',
-              'GSETTINGS_BACKEND=memory',
-              'GDK_DEBUG=default-settings',
-              'GTK_CSD=1',
-              'G_ENABLE_DIAGNOSTIC=0',
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
-              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
-            ],
+       protocol: 'tap',
+       env: test_env,
        suite: 'gtk')
   if get_option('install-tests')
     conf = configuration_data()
@@ -156,63 +199,68 @@ focus_chain_tests = [
   [ 'focusable-container', 'tab-backward' ],
 ]
 
-focus_chain = executable(
-  'test-focus-chain',
+focus_chain = executable('test-focus-chain',
   ['test-focus-chain.c'],
   dependencies: libgtk_dep,
   install: get_option('install-tests'),
-  install_dir: testexecdir
+  install_dir: testexecdir,
 )
 
 foreach test : focus_chain_tests
-  test(test[0] + ' ' + test[1], focus_chain,
-       args: [ join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.ui'),
-               join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.' + test[1]) ],
-       env: [ 'GIO_USE_VOLUME_MONITOR=unix',
-              'GSETTINGS_BACKEND=memory',
-              'GDK_DEBUG=default-settings',
-              'GTK_CSD=1',
-              'G_ENABLE_DIAGNOSTIC=0',
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-             ],
-       suite: [ 'gtk', 'focus' ])
+  test(test[0] + ' ' + test[1],
+    focus_chain,
+    args: [
+      meson.current_source_dir() / 'focus-chain' / test[0] + '.ui',
+      meson.current_source_dir() / 'focus-chain' / test[0] + '.' + test[1],
+    ],
+    env: test_env,
+    suite: [ 'gtk', 'focus' ],
+  )
 endforeach
 
-
 if get_option('install-tests')
-  foreach t : tests
+  foreach t: tests
     test_name = t.get(0)
     conf = configuration_data()
     conf.set('testexecdir', testexecdir)
     conf.set('test', test_name)
-    configure_file(input: 'gtk.test.in',
-                   output: '@0@.test'.format(test_name),
-                   configuration: conf,
-                   install_dir: testdatadir)
+    configure_file(
+      input: 'gtk.test.in',
+      output: '@0@.test'.format(test_name),
+      configuration: conf,
+      install_dir: testdatadir,
+    )
   endforeach
 
   install_subdir('icons', install_dir: testexecdir)
   install_subdir('ui', install_dir: testexecdir)
-
 endif
 
 if get_option ('profiler')
+  test('performance-layout',
+    test_performance,
+    args: [
+      '--mark',
+      'size allocation',
+      meson.current_build_dir() / '../../demos/widget-factory/gtk4-widget-factory',
+    ],
+    env: [
+      'GTK_THEME=Empty',
+      'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
+    ],
+    suite: [ 'gtk' ],
+  )
 
-  test('performance-layout', test_performance,
-       args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), 
'../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Empty',
-              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
-       suite: [ 'gtk' ])
-
-endif
-
-if get_option ('profiler')
-
-  test('performance-snapshot', test_performance,
-       args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), 
'../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Empty',
-              'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir) ],
-       suite: [ 'gtk' ])
-
+  test('performance-snapshot',
+    test_performance,
+    args: [
+      '--mark', 'widget snapshot',
+      meson.current_build_dir() / '../../demos/widget-factory/gtk4-widget-factory',
+    ],
+    env: [
+      'GTK_THEME=Empty',
+      'GSETTINGS_SCHEMA_DIR=@0@'.format(gtk_schema_build_dir),
+    ],
+    suite: [ 'gtk' ],
+  )
 endif


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