tests: Use the test ATContext for every test

Otherwise we're going to need a full desktop session in order to run the
test suite.
This commit is contained in:
Emmanuele Bassi 2020-10-09 18:17:04 +01:00
parent e6c5d57ffe
commit 88113956a3
9 changed files with 83 additions and 69 deletions

View File

@ -9,14 +9,13 @@ test_change = executable(
install: get_option('install-tests'),
install_dir: testexecdir,
)
test('change', test_change,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'css')
args: [ '--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css',
)
test_data = [
'test1.css', 'test1.ui', 'test1.nodes',

View File

@ -1,3 +1,12 @@
csstest_env = environment()
csstest_env.set('GTK_TEST_ACCESSIBLE', '1')
csstest_env.set('GSK_RENDERER', 'cairo')
csstest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
csstest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
csstest_env.set('GIO_USE_VFS', 'local')
csstest_env.set('GSETTINGS_BACKEND', 'memory')
csstest_env.set('G_ENABLE_DIAGNOSTIC', '0')
subdir('parser')
subdir('nodes')
subdir('style')
@ -14,10 +23,7 @@ test_api = executable('api', 'api.c',
test('api', test_api,
args: ['--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
env: csstest_env,
suite: 'css')
test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
@ -29,10 +35,7 @@ test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
test('data', test_data,
args: ['--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
env: csstest_env,
suite: 'css')
if get_option('install-tests')
@ -46,20 +49,24 @@ endif
if false and get_option ('profiler')
adwaita_env = csstest_env
adwaita_env.set('GTK_THEME', 'Adwaita')
test('performance-adwaita', test_performance,
args: [ '--mark', 'css validation',
'--name', 'performance-adwaita',
'--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Adwaita' ],
env: adwaita_env,
suite: [ 'css' ])
empty_env = csstest_env
empty_env.set('GTK_THEME', 'Empty')
test('performance-empty', test_performance,
args: [ '--mark', 'css validation',
'--name', 'performance-empty',
'--output', join_paths(meson.current_build_dir(), 'output'),
join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
env: [ 'GTK_THEME=Empty' ],
env: empty_env,
suite: [ 'css' ])
endif

View File

@ -7,13 +7,11 @@ test_nodes = executable('test-css-nodes', 'test-css-nodes.c',
install_dir: testexecdir,
dependencies: libgtk_dep)
test('nodes', test_nodes,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'css')
args: [ '--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css',
)
test_data = [
'box.ltr.nodes',
@ -77,5 +75,4 @@ if get_option('install-tests')
install_dir: testdatadir)
install_data(test_data, install_dir: testexecdir)
endif

View File

@ -17,13 +17,11 @@ test_style = executable(
install_dir: testexecdir,
)
test('style', test_style,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'css')
args: [ '--tap', '-k' ],
protocol: 'tap',
env: csstest_env,
suite: 'css',
)
test_data = [
'adjacent-states.css',
@ -65,5 +63,4 @@ if get_option('install-tests')
install_dir: testdatadir)
install_data(test_data, install_dir: testexecdir)
endif

View File

@ -16,28 +16,31 @@ tests = [
foreach t : tests
test_exe = executable(t, '@0@.c'.format(t),
c_args: common_cflags,
dependencies: libgtk_dep,
install: get_option('install-tests'),
install_dir: testexecdir)
c_args: common_cflags,
dependencies: libgtk_dep,
install: get_option('install-tests'),
install_dir: testexecdir,
)
test(t, test_exe,
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
suite: 'gdk')
args: [ '--tap', '-k' ],
protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
],
suite: 'gdk',
)
if get_option('install-tests')
test_cdata = configuration_data()
test_cdata.set('testexecdir', testexecdir)
test_cdata.set('test', t)
configure_file(input: 'gdk.test.in',
output: '@0@.test'.format(t),
configuration: test_cdata,
install: true,
install_dir: testdatadir)
output: '@0@.test'.format(t),
configuration: test_cdata,
install: true,
install_dir: testdatadir,
)
endif
endforeach

View File

@ -101,6 +101,7 @@ foreach renderer : renderers
join_paths(meson.current_source_dir(), 'compare', test + '.png')],
env: [
'GSK_RENDERER=' + renderer[0],
'GTK_TEST_ACCESSIBLE=1',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
@ -178,6 +179,7 @@ foreach test : node_parser_tests
],
env: [
'GSK_RENDERER=opengl',
'GTK_TEST_ACCESSIBLE=1',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
@ -211,6 +213,7 @@ foreach t : tests
protocol: 'tap',
env: [
'GSK_RENDERER=cairo',
'GTK_TEST_ACCESSIBLE=1',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],

View File

@ -146,6 +146,15 @@ is_debug = get_option('buildtype').startswith('debug')
test_cargs = []
test_env = environment()
test_env.set('GTK_TEST_ACCESSIBLE', '1')
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('GIO_USE_VFS', 'local')
test_env.set('GSETTINGS_BACKEND', 'memory')
test_env.set('G_ENABLE_DIAGNOSTIC', '0')
if os_unix
# tests += [['defaultvalue']] # disabled in Makefile.am as well
test_cargs += ['-DHAVE_UNIX_PRINT_WIDGETS']
@ -182,11 +191,7 @@ foreach t : tests
args: [ '--tap', '-k' ],
protocol: 'tap',
timeout: test_timeout,
env: [
'GSK_RENDERER=cairo',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
],
env: test_env,
suite: ['gtk'] + test_extra_suites,
should_fail: expect_fail,
)
@ -203,10 +208,7 @@ if add_languages('cpp', required: false)
test('c++ keywords', test_exe,
args: [ '--tap', '-k' ],
#protocol: 'tap',
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
],
env: test_env,
suite: 'gtk')
if get_option('install-tests')
conf = configuration_data()
@ -254,10 +256,7 @@ 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: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
],
env: test_env,
suite: [ 'gtk', 'focus' ])
endforeach
@ -282,14 +281,17 @@ endif
if false and get_option ('profiler')
performance_env = test_env
performance_env.set('GTK_THEME', 'Empty')
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' ],
env: performance_env,
suite: [ 'gtk' ])
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' ],
env: performance_end,
suite: [ 'gtk' ])
endif

View File

@ -450,6 +450,16 @@ xfails = [
'label-sizing.ui',
]
reftest_env = environment()
reftest_env.set('GTK_TEST_ACCESSIBLE', '1')
reftest_env.set('GSK_RENDERER', 'opengl')
reftest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
reftest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
reftest_env.set('GIO_USE_VFS', 'local')
reftest_env.set('GSETTINGS_BACKEND', 'memory')
reftest_env.set('G_ENABLE_DIAGNOSTIC', '0')
reftest_env.set('REFTEST_MODULE_DIR', meson.current_build_dir())
foreach testname : testdata
if testname.endswith('.ui') and not testname.endswith('.ref.ui')
test('reftest ' + testname, gtk_reftest,
@ -459,12 +469,7 @@ foreach testname : testdata
join_paths(meson.current_source_dir(), testname),
],
protocol: 'tap',
env: [
'GSK_RENDERER=opengl',
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir())
],
env: reftest_env,
suite: 'reftest',
should_fail: xfails.contains(testname))
endif

View File

@ -23,6 +23,7 @@ if bash.found()
env: [
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
'GTK_TEST_ACCESSIBLE=1',
'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()),
'GTK_QUERY_SETTINGS=@0@'.format(get_variable('gtk4_query_settings').full_path())
],