Merge branch '1444-install-tests' into 'master'

Resolve "the meson build doesn't support installed tests"

Closes #1444

See merge request GNOME/glib!245
This commit is contained in:
Xavier Claessens 2018-08-16 20:01:06 +00:00
commit 9a3c7eca14
2 changed files with 340 additions and 309 deletions

View File

@ -15,69 +15,67 @@ giotypefuncs_inc = custom_target(
command: [gengiotypefuncs_prog, '@OUTPUT@', '@INPUT@'])
# Test programs buildable on all platforms
gio_tests = [
'appmonitor',
'async-close-output-stream',
'async-splice-output-stream',
'buffered-input-stream',
'buffered-output-stream',
'cancellable',
'contexts',
'contenttype',
'converter-stream',
'credentials',
'data-input-stream',
'data-output-stream',
'defaultvalue',
'fileattributematcher',
'filter-streams',
'giomodule',
'gsubprocess',
'g-file',
'g-file-info',
'g-icon',
'gdbus-addresses',
'gdbus-message',
'inet-address',
'io-stream',
'memory-input-stream',
'memory-output-stream',
'monitor',
'mount-operation',
'network-address',
'network-monitor',
'network-monitor-race',
'permission',
'pollable',
'proxy-test',
'readwrite',
'simple-async-result',
'simple-proxy',
'sleepy-stream',
'socket',
'socket-listener',
'socket-service',
'srvtarget',
'task',
'vfs',
'volumemonitor',
'glistmodel',
'testfilemonitor',
'thumbnail-verification',
'tls-certificate',
'tls-interaction',
]
slow_tests = [
'actions',
'gdbus-export',
'gdbus-threading',
'testfilemonitor',
]
# FIXME: We are using list of dictionnaries until we can depend on Meson 0.48.0
# that supports '+=' operator on dictionnaries.
gio_tests = [{
'appmonitor' : {},
'async-close-output-stream' : {},
'async-splice-output-stream' : {},
'buffered-input-stream' : {},
'buffered-output-stream' : {},
'cancellable' : {},
'contexts' : {},
'contenttype' : {},
'converter-stream' : {},
'credentials' : {},
'data-input-stream' : {},
'data-output-stream' : {},
'defaultvalue' : {'extra_sources' : [giotypefuncs_inc]},
'fileattributematcher' : {},
'filter-streams' : {},
'giomodule' : {},
'gsubprocess' : {},
'g-file' : {},
'g-file-info' : {},
'g-icon' : {},
'gdbus-addresses' : {},
'gdbus-message' : {},
'inet-address' : {},
'io-stream' : {},
'memory-input-stream' : {},
'memory-output-stream' : {},
'monitor' : {},
'mount-operation' : {},
'network-address' : {},
'network-monitor' : {},
'network-monitor-race' : {},
'permission' : {},
'pollable' : {},
'proxy-test' : {},
'readwrite' : {},
'simple-async-result' : {},
'simple-proxy' : {},
'sleepy-stream' : {},
'socket' : {},
'socket-listener' : {},
'socket-service' : {},
'srvtarget' : {},
'task' : {},
'vfs' : {},
'volumemonitor' : {},
'glistmodel' : {},
'testfilemonitor' : {'suite' : ['slow']},
'thumbnail-verification' : {},
'tls-certificate' : {'extra_sources' : ['gtesttlsbackend.c']},
'tls-interaction' : {'extra_sources' : ['gtesttlsbackend.c']},
}]
test_extra_programs = [
['gdbus-connection-flush-helper'],
['gdbus-testserver'],
]
# FIXME: We are using list of dictionnaries until we can depend on Meson 0.48.0
# that supports '+=' operator on dictionnaries.
test_extra_programs = [{
'gdbus-connection-flush-helper' : {},
'gdbus-testserver' : {},
}]
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
@ -110,49 +108,57 @@ endif
if dbus1_dep.found()
glib_conf.set('HAVE_DBUS1', 1)
exe = executable('gdbus-serialization',
'gdbus-serialization.c', 'gdbus-tests.c',
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps + [dbus1_dep])
test('gdbus-serialization', exe, env : test_env, suite : ['gio'])
gio_tests += [{
'gdbus-serialization' : {
'extra_sources' : ['gdbus-tests.c'],
'dependencies' : [dbus1_dep],
}
}]
endif
# Test programs buildable on UNIX only
if host_machine.system() != 'windows'
gio_tests += [
'file',
'gdbus-peer',
'gdbus-peer-object-manager',
'live-g-file',
'socket-address',
'stream-rw_all',
'unix-fd',
'unix-mounts',
'unix-streams',
'g-file-info-filesystem-readonly',
'gschema-compile',
'trash',
]
gio_tests += [{
'file' : {},
'gdbus-peer' : {'dependencies' : [libgdbus_example_objectmanager_dep]},
'gdbus-peer-object-manager' : {},
'live-g-file' : {},
'socket-address' : {},
'stream-rw_all' : {},
'unix-fd' : {},
'unix-mounts' : {},
'unix-streams' : {},
'g-file-info-filesystem-readonly' : {},
'gschema-compile' : {'install' : false},
'trash' : {},
}]
# Uninstalled because of the check-for-executable logic in DesktopAppInfo
# unable to find the installed executable
if not glib_have_cocoa
gio_tests += [
'appinfo',
'desktop-app-info',
]
gio_tests += [{
'appinfo' : {
'install' : false,
},
'desktop-app-info' : {
'install' : false,
},
}]
endif
test_extra_programs += [
['basic-application'],
['dbus-launch'],
['appinfo-test'],
]
test_extra_programs += [{
'basic-application' : {},
'dbus-launch' : {},
'appinfo-test' : {},
}]
if not glib_have_cocoa
test_extra_programs += [['apps']]
gio_tests += ['mimeapps']
test_extra_programs += [{
'apps' : {},
}]
gio_tests += [{
'mimeapps' : {},
}]
endif
# Test programs that need to bring up a session bus (requires dbus-daemon)
@ -181,71 +187,61 @@ if host_machine.system() != 'windows'
'--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
'@INPUT@'])
gio_dbus_tests = [
['actions', [], []],
['gdbus-auth', [], []],
['gdbus-bz627724', [], []],
['gdbus-close-pending', [], []],
['gdbus-connection', [], []],
['gdbus-connection-loss', [], []],
['gdbus-connection-slow', [], []],
['gdbus-error', [], []],
['gdbus-exit-on-close', [], []],
['gdbus-export', [], []],
['gdbus-introspection', [], []],
['gdbus-names', [], []],
['gdbus-proxy', [], []],
['gdbus-proxy-threads', [], [dbus1_dep]],
['gdbus-proxy-well-known-name', [], []],
['gdbus-test-codegen', [gdbus_test_codegen_generated], []],
['gdbus-threading', [], []],
['gmenumodel', [], []],
['gnotification', ['gnotification-server.c'], []],
]
extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
gio_tests += [{
'actions' : {
'extra_sources' : extra_sources,
'suite' : ['slow'],
},
'gdbus-auth' : {'extra_sources' : extra_sources},
'gdbus-bz627724' : {'extra_sources' : extra_sources},
'gdbus-close-pending' : {'extra_sources' : extra_sources},
'gdbus-connection' : {'extra_sources' : extra_sources},
'gdbus-connection-loss' : {'extra_sources' : extra_sources},
'gdbus-connection-slow' : {'extra_sources' : extra_sources},
'gdbus-error' : {'extra_sources' : extra_sources},
'gdbus-exit-on-close' : {'extra_sources' : extra_sources},
'gdbus-export' : {
'extra_sources' : extra_sources,
'suite' : ['slow'],
},
'gdbus-introspection' : {'extra_sources' : extra_sources},
'gdbus-names' : {'extra_sources' : extra_sources},
'gdbus-proxy' : {'extra_sources' : extra_sources},
'gdbus-proxy-threads' : {
'extra_sources' : extra_sources,
'dependencies' : [dbus1_dep],
},
'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources},
'gdbus-test-codegen' : {
'extra_sources' : [extra_sources, gdbus_test_codegen_generated],
},
'gdbus-threading' : {
'extra_sources' : extra_sources,
'suite' : ['slow'],
},
'gmenumodel' : {'extra_sources' : extra_sources},
'gnotification' : {
'extra_sources' : [extra_sources, 'gnotification-server.c'],
},
'gdbus-test-codegen-old' : {
'source' : 'gdbus-test-codegen.c',
'extra_sources' : [extra_sources, gdbus_test_codegen_generated],
'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
},
'gapplication' : {'extra_sources' : extra_sources},
'gdbus-unix-addresses' : {},
}]
if not glib_have_cocoa
gio_dbus_tests += [['dbus-appinfo', [], []]]
gio_tests += [{
'dbus-appinfo' : {
'extra_sources' : extra_sources,
},
}]
endif
# separate loop because extra source files for each test
foreach dbus_test : gio_dbus_tests
test_name = dbus_test[0]
extra_src = dbus_test[1]
extra_deps = dbus_test[2]
exe = executable(test_name, '@0@.c'.format(test_name),
'gdbus-sessionbus.c', 'gdbus-tests.c', extra_src,
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps + extra_deps)
# These tests may take more than 30 seconds to run on the CI infrastructure
if slow_tests.contains(test_name)
test(test_name, exe, env : test_env, timeout : 120, suite : ['gio', 'slow'])
else
test(test_name, exe, env : test_env, suite : ['gio'])
endif
endforeach
exe = executable('gdbus-test-codegen-old', 'gdbus-test-codegen.c',
'gdbus-sessionbus.c', 'gdbus-tests.c', gdbus_test_codegen_generated,
install : false,
c_args : test_c_args + ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36', '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
dependencies : common_gio_tests_deps)
test('gdbus-test-codegen-old', exe, env : test_env, suite : ['gio'])
# There is already a gapplication exe target in gio so need to use a
# different name for the unit test executable, since we can't have two
# targets of the same name even if in different directories
# (FIXME: just rename source file to gapplication-test.c)
if not glib_have_cocoa
exe = executable('gapplication-test', 'gapplication.c',
'gdbus-sessionbus.c', 'gdbus-tests.c',
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps)
endif
test('gapplication', exe, env : test_env, suite : ['gio'])
gio_tests += ['gdbus-unix-addresses']
endif # have_dbus_daemon
# This test is currently unreliable
@ -254,125 +250,100 @@ if host_machine.system() != 'windows'
c_args : test_c_args,
dependencies : common_gio_tests_deps)
exe = executable('gdbus-connection-flush', 'gdbus-connection-flush.c',
'test-io-stream.c', 'test-pipe-unix.c',
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps)
test('gdbus-connection-flush', exe, env : test_env, suite : ['gio'])
exe = executable('gdbus-non-socket', 'gdbus-non-socket.c',
'gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c',
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps)
test('gdbus-non-socket', exe, env : test_env, suite : ['gio'])
gio_tests += [{
'gdbus-connection-flush' : {
'extra_sources' : ['test-io-stream.c', 'test-pipe-unix.c'],
},
'gdbus-non-socket' : {
'extra_sources' : ['gdbus-tests.c', 'test-io-stream.c', 'test-pipe-unix.c'],
},
}]
# Generate test.mo from de.po using msgfmt
msgfmt = find_program('msgfmt', required : false)
if msgfmt.found()
subdir('de/LC_MESSAGES')
# gsettings target exe already exists in gio directory
exe = executable('gsettings-test', 'gsettings.c', test_mo,
install : false,
c_args : test_c_args + [
'-DSRCDIR="@0@"'.format(meson.current_source_dir()),
'-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir),
],
dependencies : common_gio_tests_deps)
test('gsettings', exe, env : test_env, suite : ['gio'])
gio_tests += [{
'gsettings' : {
'extra_sources' : [test_mo],
'c_args' : ['-DSRCDIR="@0@"'.format(meson.current_source_dir()),
'-DTEST_LOCALE_PATH="@0@"'.format(test_mo_dir)],
'install' : false,
},
}]
endif
endif # unix
# Test programs buildable on Windows only
if host_machine.system() == 'windows'
gio_tests += ['win32-streams']
gio_tests += [{'win32-streams' : {}}]
endif
if cc.get_id() != 'msvc'
gio_tests += [ 'autoptr' ]
gio_tests += [{
'autoptr-gio' : {
'source' : 'autoptr.c',
},
}]
endif
foreach test_name : gio_tests
extra_deps = []
srcs = ['@0@.c'.format(test_name)]
# conflicts with glib/tests/autoptr, can't have two targets with same name
if test_name == 'autoptr'
test_name = 'autoptr-gio'
elif test_name == 'defaultvalue'
srcs += [giotypefuncs_inc]
elif test_name == 'gdbus-peer'
# This is peer to peer so it doesn't need a session bus, so we can run
# it automatically as a test by default
extra_deps = [libgdbus_example_objectmanager_dep]
elif test_name == 'tls-certificate' or test_name == 'tls-interaction'
srcs += ['gtesttlsbackend.c']
endif
exe = executable(test_name, srcs,
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps + extra_deps)
# These tests may take more than 30 seconds to run on the CI infrastructure
if slow_tests.contains(test_name)
test(test_name, exe, env : test_env, timeout : 120, suite : ['gio', 'slow'])
else
test(test_name, exe, env : test_env, suite : ['gio'])
endif
endforeach
uninstalled_test_extra_programs = [
['gio-du'],
['echo-server'],
['filter-cat'],
['gapplication-example-actions'],
['gapplication-example-cmdline'],
['gapplication-example-cmdline2'],
['gapplication-example-cmdline3'],
['gapplication-example-cmdline4'],
['gapplication-example-dbushooks'],
['gapplication-example-open'],
['gdbus-daemon', gdbus_daemon_sources],
['gdbus-example-export'],
['gdbus-example-own-name'],
['gdbus-example-peer'],
['gdbus-example-proxy-subclass'],
['gdbus-example-server'],
['gdbus-example-subtree'],
['gdbus-example-watch-name'],
['gdbus-example-watch-proxy'],
['gsubprocess-testprog'],
['httpd'],
['proxy'],
['resolver'],
['send-data'],
['socket-server'],
['socket-client', ['gtlsconsoleinteraction.c']],
test_extra_programs += [{
'gio-du' : {'install' : false},
'echo-server' : {'install' : false},
'filter-cat' : {'install' : false},
'gapplication-example-actions' : {'install' : false},
'gapplication-example-cmdline' : {'install' : false},
'gapplication-example-cmdline2' : {'install' : false},
'gapplication-example-cmdline3' : {'install' : false},
'gapplication-example-cmdline4' : {'install' : false},
'gapplication-example-dbushooks' : {'install' : false},
'gapplication-example-open' : {'install' : false},
'gdbus-daemon' : {
'extra_sources' : gdbus_daemon_sources,
'install' : false,
},
'gdbus-example-export' : {'install' : false},
'gdbus-example-own-name' : {'install' : false},
'gdbus-example-peer' : {'install' : false},
'gdbus-example-proxy-subclass' : {'install' : false},
'gdbus-example-server' : {'install' : false},
'gdbus-example-subtree' : {'install' : false},
'gdbus-example-watch-name' : {'install' : false},
'gdbus-example-watch-proxy' : {'install' : false},
'gsubprocess-testprog' : {'install' : false},
'httpd' : {'install' : false},
'proxy' : {'install' : false},
'resolver' : {'install' : false},
'send-data' : {'install' : false},
'socket-server' : {'install' : false},
'socket-client' : {
'extra_sources' : ['gtlsconsoleinteraction.c'],
'install' : false,
},
# These three are manual-run tests because they need a session bus but don't bring one up themselves
# FIXME: these build but don't seem to work!
['gdbus-example-objectmanager-client', [], [libgdbus_example_objectmanager_dep]],
['gdbus-example-objectmanager-server', [], [libgdbus_example_objectmanager_dep]],
['gdbus-test-fixture', [], [libgdbus_example_objectmanager_dep]],
]
'gdbus-example-objectmanager-client' : {
'dependencies' : [libgdbus_example_objectmanager_dep],
'install' : false,
},
'gdbus-example-objectmanager-server' : {
'dependencies' : [libgdbus_example_objectmanager_dep],
'install' : false,
},
'gdbus-test-fixture' : {
'dependencies' : [libgdbus_example_objectmanager_dep],
'install' : false,
},
}]
if host_machine.system() != 'windows'
uninstalled_test_extra_programs += [['gdbus-example-unix-fd-client']]
test_extra_programs += [{
'gdbus-example-unix-fd-client' : {
'install' : false,
},
}]
endif
foreach extra_program : uninstalled_test_extra_programs + test_extra_programs
srcs = ['@0@.c'.format(extra_program[0])]
if extra_program.length() > 1
srcs += extra_program[1]
endif
extra_deps = []
if extra_program.length() > 2
extra_deps = extra_program[2]
endif
executable(extra_program[0], srcs,
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps + extra_deps)
endforeach
if not meson.is_cross_build() or meson.has_exe_wrapper()
plugin_resources_c = custom_target('plugin-resources.c',
@ -441,13 +412,58 @@ if not meson.is_cross_build() or meson.has_exe_wrapper()
copy : true,
install : false)
exe = executable('resources', 'resources.c', test_gresource,
test_resources_c, test_resources2_c, test_resources2_h,
install : false,
c_args : test_c_args,
dependencies : common_gio_tests_deps)
test('resources', exe, env : test_env, suite : ['gio'])
gio_tests += [{
'resources' : {
'extra_sources' : [test_gresource, test_resources_c, test_resources2_c,
test_resources2_h],
},
}]
endif
foreach test_dict : gio_tests
foreach test_name, extra_args : test_dict
source = extra_args.get('source', test_name + '.c')
extra_sources = extra_args.get('extra_sources', [])
install = installed_tests_enabled and extra_args.get('install', true)
if install
test_conf = configuration_data()
test_conf.set('installed_tests_dir', installed_tests_execdir)
test_conf.set('program', test_name)
configure_file(
input: installed_tests_template,
output: test_name + '.test',
install_dir: installed_tests_metadir,
configuration: test_conf
)
endif
exe = executable(test_name, [source, extra_sources],
c_args : test_c_args + extra_args.get('c_args', []),
dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
install_dir: installed_tests_execdir,
install: install,
)
suite = ['gio'] + extra_args.get('suite', [])
timeout = suite.contains('slow') ? 120 : 30
test(test_name, exe, env : test_env, timeout : timeout, suite : suite)
endforeach
endforeach
foreach program_dict : test_extra_programs
foreach program_name, extra_args : program_dict
source = extra_args.get('source', program_name + '.c')
extra_sources = extra_args.get('extra_sources', [])
install = installed_tests_enabled and extra_args.get('install', true)
executable(program_name, [source, extra_sources],
c_args : test_c_args,
dependencies : common_gio_tests_deps + extra_args.get('dependencies', []),
install_dir : installed_tests_execdir,
install : install,
)
endforeach
endforeach
# FIXME: subdir('services')
subdir('modules')

View File

@ -1,47 +1,3 @@
gobject_tests = [
'qdata',
'boxed',
'enums',
'param',
'threadtests',
'dynamictests',
'binding',
'properties',
'reference',
'value',
'type',
'private',
'closure',
'object',
'signal-handler',
'ifaceproperties',
]
# FIXME: put common bits of test environment() in one location
# Not entirely random of course, but at least it changes over time
random_number = minor_version + meson.version().split('.').get(1).to_int()
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env.set('G_DEBUG', 'gc-friendly')
test_env.set('MALLOC_CHECK_', '2')
test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
foreach test_name : gobject_tests
deps = [libm, thread_dep, libglib_dep, libgobject_dep]
test_src = '@0@.c'.format(test_name)
# private is an existing or reserved target it seems
if test_name == 'private'
test_name = 'gobject-private'
endif
exe = executable(test_name, test_src,
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"'],
dependencies : deps,
)
test(test_name, exe, env : test_env, suite : ['gobject'])
endforeach
marshalers_h = custom_target('marshalers_h',
output : 'marshalers.h',
input : 'marshalers.list',
@ -70,12 +26,71 @@ marshalers_c = custom_target('marshalers_c',
],
)
exe = executable('signals',
'signals.c', marshalers_h, marshalers_c,
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"'],
dependencies : deps,
)
test('signals', exe, env : test_env, suite : ['gobject'])
gobject_tests = {
'qdata' : {},
'boxed' : {},
'enums' : {},
'param' : {},
'threadtests' : {},
'dynamictests' : {},
'binding' : {},
'properties' : {},
'reference' : {},
'value' : {},
'type' : {},
'gobject-private' : {
'source' : 'private.c',
},
'closure' : {},
'object' : {},
'signal-handler' : {},
'ifaceproperties' : {},
'signals' : {
'source' : ['signals.c', marshalers_h, marshalers_c],
},
}
# FIXME: put common bits of test environment() in one location
# Not entirely random of course, but at least it changes over time
random_number = minor_version + meson.version().split('.').get(1).to_int()
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env.set('G_DEBUG', 'gc-friendly')
test_env.set('MALLOC_CHECK_', '2')
test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
test_deps = [libm, thread_dep, libglib_dep, libgobject_dep]
test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"']
foreach test_name, extra_args : gobject_tests
source = extra_args.get('source', test_name + '.c')
install = installed_tests_enabled and extra_args.get('install', true)
if install
test_conf = configuration_data()
test_conf.set('installed_tests_dir', installed_tests_execdir)
test_conf.set('program', test_name)
configure_file(
input: installed_tests_template,
output: test_name + '.test',
install_dir: installed_tests_metadir,
configuration: test_conf
)
endif
exe = executable(test_name, source,
c_args : test_cargs + extra_args.get('c_args', []),
dependencies : test_deps + extra_args.get('dependencies', []),
install_dir: installed_tests_execdir,
install: install,
)
suite = ['gobject'] + extra_args.get('suite', [])
timeout = suite.contains('slow') ? 120 : 30
test(test_name, exe, env : test_env, timeout : timeout, suite : suite)
endforeach
test(
'mkenums.py',