build: Modernize and deduplicate setting up test targets
Get rid of the duplication by rolling (almost) every test into a loop. We now iterate over an array containing at least the name and list of sources. To account for some differences between individual tests, we allow an optional third array consisting of a dictionary for extra arguments. In particular we ensure that the `test()` target now always depends on the test binary, so that it will get properly rebuilt on changes to the sources. Note, that we're resorting in a separate commit, to ease reviewing. Signed-off-by: Evangelos Ribeiro Tzaras <devrtz@fortysixandtwo.eu> Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/798>
This commit is contained in:
committed by
Marge Bot
parent
fec9e953ae
commit
93a5c1911d
@@ -46,140 +46,55 @@ test_includes = include_directories('.')
|
|||||||
subdir('mock')
|
subdir('mock')
|
||||||
subdir('services')
|
subdir('services')
|
||||||
|
|
||||||
test_sources = ['test-emergency-call-types.c']
|
tests = [
|
||||||
t = executable(
|
['emergency-call-types', ['test-emergency-call-types.c']],
|
||||||
'emergency-call-types',
|
['manager', ['test-manager.c'], {'extra_test_deps' : [calls_plugins]}],
|
||||||
test_sources,
|
[
|
||||||
c_args: test_cflags,
|
'plugins',
|
||||||
link_args: test_link_args,
|
['test-plugins.c', calls_sources],
|
||||||
pie: true,
|
{'extra_test_deps' : [calls_plugins]},
|
||||||
link_with: [calls_vala, libcalls],
|
],
|
||||||
dependencies: calls_deps,
|
['util', ['test-util.c']],
|
||||||
include_directories: [calls_includes],
|
['ui-call', ['test-ui-call.c', 'mock-call.c']],
|
||||||
)
|
['contacts', ['test-contacts.c']],
|
||||||
test('emergency-call-types', t, env: test_env)
|
['settings', ['test-settings.c']],
|
||||||
|
['dbus', ['test-dbus.c', generated_dbus_sources]],
|
||||||
|
[
|
||||||
|
'ringer',
|
||||||
|
['mock-call.c', 'test-ringer.c'],
|
||||||
|
{'extra_link_with' : libfeedback},
|
||||||
|
],
|
||||||
|
['service-providers', ['test-service-providers.c']],
|
||||||
|
]
|
||||||
|
|
||||||
test_sources = ['test-service-providers.c']
|
foreach t : tests
|
||||||
t = executable(
|
test_name = t[0]
|
||||||
'service-providers',
|
test_sources = t[1]
|
||||||
test_sources,
|
link_with = [calls_vala, libcalls]
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('service-providers', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['test-manager.c']
|
if t.length() == 3 and t[2].has_key('extra_link_with')
|
||||||
|
link_with += t[2]['extra_link_with']
|
||||||
|
endif
|
||||||
|
|
||||||
t = executable(
|
exe = executable(
|
||||||
'manager',
|
test_name,
|
||||||
test_sources,
|
test_sources,
|
||||||
c_args: test_cflags,
|
c_args: test_cflags,
|
||||||
link_args: test_link_args,
|
link_args: test_link_args,
|
||||||
pie: true,
|
pie: true,
|
||||||
link_with: [calls_vala, libcalls],
|
link_with: link_with,
|
||||||
dependencies: calls_deps,
|
dependencies: calls_deps,
|
||||||
include_directories: [calls_includes],
|
include_directories: [calls_includes, test_includes],
|
||||||
)
|
)
|
||||||
test('manager', t, env: test_env, depends: calls_plugins)
|
|
||||||
|
|
||||||
test_sources = ['test-plugins.c']
|
test_deps = [exe]
|
||||||
|
if t.length() == 3 and t[2].has_key('extra_test_deps')
|
||||||
|
test_deps += t[2]['extra_test_deps']
|
||||||
|
endif
|
||||||
|
|
||||||
t = executable(
|
test(t[0], exe, env: test_env, depends: test_deps)
|
||||||
'plugins',
|
endforeach
|
||||||
test_sources,
|
|
||||||
calls_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('plugins', t, env: test_env, depends: calls_plugins)
|
|
||||||
|
|
||||||
test_sources = ['test-util.c']
|
|
||||||
t = executable(
|
|
||||||
'util',
|
|
||||||
test_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('util', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['test-ui-call.c', 'mock-call.c', 'mock-call.h']
|
|
||||||
t = executable(
|
|
||||||
'ui-call',
|
|
||||||
test_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('ui-call', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['mock-call.c', 'mock-call.h', 'test-ringer.c']
|
|
||||||
|
|
||||||
t = executable(
|
|
||||||
'ringer',
|
|
||||||
test_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls, libfeedback],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('ringer', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['test-contacts.c']
|
|
||||||
t = executable(
|
|
||||||
'contacts',
|
|
||||||
test_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('contacts', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['test-settings.c']
|
|
||||||
t = executable(
|
|
||||||
'settings',
|
|
||||||
test_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('settings', t, env: test_env)
|
|
||||||
|
|
||||||
test_sources = ['test-dbus.c']
|
|
||||||
t = executable(
|
|
||||||
'dbus',
|
|
||||||
test_sources,
|
|
||||||
generated_dbus_sources,
|
|
||||||
c_args: test_cflags,
|
|
||||||
link_args: test_link_args,
|
|
||||||
pie: true,
|
|
||||||
link_with: [calls_vala, libcalls],
|
|
||||||
dependencies: calls_deps,
|
|
||||||
include_directories: [calls_includes],
|
|
||||||
)
|
|
||||||
test('dbus', t, env: test_env)
|
|
||||||
|
|
||||||
dbus_run_session = find_program('dbus-run-session')
|
dbus_run_session = find_program('dbus-run-session')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user