File: meson.build

package info (click to toggle)
dbus-python 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,708 kB
  • sloc: ansic: 9,653; python: 4,664; makefile: 597; sh: 428
file content (195 lines) | stat: -rw-r--r-- 5,766 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Copyright 2022 Collabora Ltd.
# SPDX-License-Identifier: MIT

installed_testdir = get_option('libexecdir') / 'installed-tests' / meson.project_name() / get_option('installed_tests_subdir')
installed_test_testdir = installed_testdir / 'test'
installed_test_metadir = get_option('datadir') / 'installed-tests' / meson.project_name() / get_option('installed_tests_subdir')
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

build_time_dbus_run_session_args = [
    '--config-file', 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']
embed_dep = py.dependency(embed: true, required: get_option('tests'))

if embed_dep.found()
    foreach test_case : compiled_test_cases
        exe = executable(
            'test-' + test_case,
            test_case + '.c',
            dependencies: [
                dbus_dep.partial_dependency(compile_args: true, includes: true),
                embed_dep,
            ],
            install: get_option('installed_tests'),
            install_dir: installed_test_testdir,
            include_directories: project_include_directories,
        )
        test(
            test_case,
            dbus_run_session,
            args: build_time_dbus_run_session_args + [exe],
            env: test_env,
            protocol: 'tap',
        )

        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
endif

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