summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-09-05 09:21:38 +0100
committerSimon McVittie <smcv@collabora.com>2022-09-05 17:35:57 +0100
commitfdab4745424c7477e5257a4fc0fff4e14ef664ef (patch)
tree72964414a4d8a49b4456d5f0962ba6925d988543 /test
parent29ac041beba6fc299fd4b5434af2382c2473e456 (diff)
Add a Meson build system
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'test')
-rw-r--r--test/compiled.test.in3
-rw-r--r--test/installable/meson.build25
-rw-r--r--test/meson.build191
-rw-r--r--test/py.test.in3
-rw-r--r--test/sh.test.in3
5 files changed, 225 insertions, 0 deletions
diff --git a/test/compiled.test.in b/test/compiled.test.in
new file mode 100644
index 0000000..66bf7af
--- /dev/null
+++ b/test/compiled.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@wrapper@ @program@
diff --git a/test/installable/meson.build b/test/installable/meson.build
new file mode 100644
index 0000000..9b21425
--- /dev/null
+++ b/test/installable/meson.build
@@ -0,0 +1,25 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+installed_test_config = {
+ 'PYTHON': py.full_path(),
+ 'G_TEST_SRCDIR': get_option('prefix') / installed_testdir,
+ 'G_TEST_BUILDDIR': get_option('prefix') / installed_testdir,
+ 'configure_input': 'Generated by build system, do not edit',
+}
+
+configure_file(
+ input: '../TestSuitePythonService.service.in',
+ output: 'TestSuitePythonService.service',
+ configuration: installed_test_config,
+ install: true,
+ install_dir: installed_test_testdir,
+)
+
+configure_file(
+ input: '../tmp-session-bus.conf.in',
+ output: 'tmp-session-bus.conf',
+ configuration: installed_test_config,
+ install: true,
+ install_dir: installed_test_testdir,
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..3539f8d
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,191 @@
+# Copyright 2022 Collabora Ltd.
+# SPDX-License-Identifier: MIT
+
+installed_testdir = get_option('libexecdir') / 'installed-tests' / meson.project_name()
+installed_test_testdir = installed_testdir / 'test'
+installed_test_metadir = get_option('datadir') / 'installed-tests' / meson.project_name()
+test_env = environment()
+test_env.set('DBUS_TOP_SRCDIR', meson.project_source_root())
+test_env.set('DBUS_TOP_BUILDDIR', meson.project_build_root())
+test_env.set('DBUS_TEST_TMPDIR', meson.project_build_root() / 'test')
+test_env.set('DBUS_TEST_UNINSTALLED', '1')
+test_env.set('DBUS_PYTHON_VERSION', meson.project_version())
+test_env.set('PYTHON', py.full_path())
+test_env.set('DBUS_FATAL_WARNINGS', '1')
+test_env.set(
+ 'PYTHONPATH',
+ ':'.join([
+ meson.project_source_root(),
+ meson.project_source_root() / 'test',
+ meson.project_build_root(),
+ meson.project_build_root() / 'test',
+ ])
+)
+
+dbus_py_test = py.extension_module(
+ 'dbus_py_test',
+ sources: [
+ 'dbus_py_test.c',
+ ],
+ dependencies: [
+ dbus_dep,
+ py.dependency(),
+ ],
+ include_directories: project_include_directories,
+ install: get_option('installed_tests'),
+ install_dir: installed_test_testdir,
+)
+
+build_time_test_config = {
+ 'PYTHON': py.full_path(),
+ 'G_TEST_SRCDIR': meson.project_source_root(),
+ 'G_TEST_BUILDDIR': meson.project_build_root(),
+ 'configure_input': 'Generated by build system, do not edit',
+}
+
+configure_file(
+ input: 'TestSuitePythonService.service.in',
+ output: 'TestSuitePythonService.service',
+ configuration: build_time_test_config,
+)
+
+tmp_session_bus_conf = configure_file(
+ input: 'tmp-session-bus.conf.in',
+ output: 'tmp-session-bus.conf',
+ configuration: build_time_test_config,
+)
+
+if get_option('installed_tests')
+ subdir('installable')
+
+ install_data(
+ 'cross-test-client.py',
+ 'cross-test-server.py',
+ 'crosstest.py',
+ 'dbus_test_utils.py',
+ 'test-service.py',
+ 'wait-for-name.py',
+ install_dir: installed_test_testdir,
+ )
+endif
+
+dbus_run_session = find_program('dbus-run-session', required: true)
+
+build_time_dbus_run_session_args = [
+ '--config-file=@0@'.format(tmp_session_bus_conf),
+ '--',
+]
+
+installed_wrapper = [
+ dbus_run_session.full_path(),
+ '--config-file=@0@'.format(
+ get_option('prefix') / installed_test_testdir / 'tmp-session-bus.conf'
+ ),
+ '--',
+ 'env',
+ 'PYTHON=' + py.full_path(),
+ 'DBUS_TOP_SRCDIR=' + (get_option('prefix') / installed_testdir),
+ 'DBUS_TOP_BUILDDIR=' + (get_option('prefix') / installed_testdir),
+]
+
+compiled_test_cases = ['import-repeatedly']
+
+foreach test_case : compiled_test_cases
+ exe = executable(
+ 'test-' + test_case,
+ test_case + '.c',
+ dependencies: [
+ py.dependency(embed: true),
+ ],
+ install: get_option('installed_tests'),
+ install_dir: installed_test_testdir,
+ )
+ test(
+ test_case,
+ dbus_run_session,
+ args: build_time_dbus_run_session_args + [exe],
+ env: test_env,
+ )
+
+ if get_option('installed_tests')
+ configure_file(
+ input: 'compiled.test.in',
+ output: 'test-' + test_case + '.test',
+ configuration: {
+ 'wrapper': ' '.join(installed_wrapper),
+ 'program': get_option('prefix') / installed_test_testdir / 'test-' + test_case,
+ },
+ install: true,
+ install_dir: installed_test_metadir,
+ )
+ endif
+endforeach
+
+py_test_cases = [
+ 'client',
+ 'exception-py3',
+ 'p2p',
+ 'signals',
+ 'standalone',
+ 'unusable-main-loop',
+]
+install_test_sources = []
+
+foreach test_case : py_test_cases
+ install_test_sources += ['test-@0@.py'.format(test_case)]
+ test(
+ test_case,
+ dbus_run_session,
+ args: build_time_dbus_run_session_args + [
+ py.full_path(),
+ files('test-' + test_case + '.py'),
+ ],
+ env: test_env,
+ )
+
+ if get_option('installed_tests')
+ configure_file(
+ input: 'py.test.in',
+ output: 'test-' + test_case + '.py.test',
+ configuration: {
+ 'wrapper': ' '.join(installed_wrapper),
+ 'python': py.full_path(),
+ 'program': get_option('prefix') / installed_test_testdir / 'test-' + test_case + '.py',
+ },
+ install: true,
+ install_dir: installed_test_metadir,
+ )
+ endif
+endforeach
+
+sh_test_cases = ['run-test']
+
+foreach test_case : sh_test_cases
+ install_test_sources += ['@0@.sh'.format(test_case)]
+ test(
+ test_case + '.sh',
+ dbus_run_session,
+ args: build_time_dbus_run_session_args + [files(test_case + '.sh')],
+ env: test_env,
+ )
+
+ if get_option('installed_tests')
+ configure_file(
+ input: 'sh.test.in',
+ output: test_case + '.sh.test',
+ configuration: {
+ 'wrapper': ' '.join(installed_wrapper),
+ 'program': get_option('prefix') / installed_test_testdir / test_case + '.sh',
+ },
+ install: true,
+ install_dir: installed_test_metadir,
+ )
+ endif
+endforeach
+
+if get_option('installed_tests')
+ install_data(
+ install_test_sources,
+ install_dir: installed_test_testdir,
+ )
+endif
diff --git a/test/py.test.in b/test/py.test.in
new file mode 100644
index 0000000..b73c083
--- /dev/null
+++ b/test/py.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@wrapper@ @python@ @program@
diff --git a/test/sh.test.in b/test/sh.test.in
new file mode 100644
index 0000000..66bf7af
--- /dev/null
+++ b/test/sh.test.in
@@ -0,0 +1,3 @@
+[Test]
+Type=session
+Exec=@wrapper@ @program@