diff --git a/.github/workflows/Containerfile b/.github/workflows/Containerfile index 17fd820e5..ca384995a 100644 --- a/.github/workflows/Containerfile +++ b/.github/workflows/Containerfile @@ -42,6 +42,9 @@ RUN apt install -y --no-install-recommends \ # Install meson RUN apt install -y --no-install-recommends meson +# Install pip +RUN apt install -y --no-install-recommends python3-pip + # Install pytest RUN apt install -y --no-install-recommends \ python3-pytest \ @@ -52,9 +55,7 @@ RUN apt install -y --no-install-recommends \ libumockdev-dev \ umockdev \ gir1.2-umockdev-1.0 - -# Install pip -RUN apt install -y --no-install-recommends python3-pip +RUN pip install --prefix=/usr pytest-tap # Install doc dependencies RUN pip install --user --break-system-packages furo">=2024.04.27" \ diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index bc1faba7a..256211090 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -1,5 +1,5 @@ env: - IMAGE_TAG: 20241204-1 + IMAGE_TAG: 20241204-4 on: workflow_call: diff --git a/tests/meson.build b/tests/meson.build index 6191e08ae..057d15179 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -284,7 +284,7 @@ enable_pytest = get_option('pytest') \ .allowed() if enable_pytest - pytest_args = [meson.current_source_dir(), '--verbose', '--log-level=DEBUG'] + pytest_args = ['--verbose', '--log-level=DEBUG'] pytest_env = environment() pytest_env.set('XDG_DESKTOP_PORTAL_PATH', xdg_desktop_portal.full_path()) @@ -323,17 +323,86 @@ if enable_pytest 'test_trash.py', 'test_wallpaper.py', ] + + template_files = [ + 'templates/access.py', + 'templates/account.py', + 'templates/appchooser.py', + 'templates/background.py', + 'templates/clipboard.py', + 'templates/email.py', + 'templates/filechooser.py', + 'templates/geoclue2.py', + 'templates/globalshortcuts.py', + 'templates/inhibit.py', + 'templates/__init__.py', + 'templates/inputcapture.py', + 'templates/lockdown.py', + 'templates/notification.py', + 'templates/print.py', + 'templates/remotedesktop.py', + 'templates/screenshot.py', + 'templates/settings.py', + 'templates/wallpaper.py', + ] + foreach pytest_file : pytest_files testname = pytest_file.replace('.py', '') test( 'pytest/@0@'.format(testname), pytest, - args: pytest_args + ['-k', testname], + args: [meson.current_source_dir()] + pytest_args + ['-k', testname], env: pytest_env, suite: ['pytest'], timeout: 120, ) endforeach + + if enable_installed_tests + install_data( + pytest_files, + '__init__.py', + 'conftest.py', + 'asan.suppression', + install_dir: installed_tests_dir / 'tests', + ) + install_data( + template_files, + install_dir: installed_tests_dir / 'tests' / 'templates', + ) + + installed_env = { + 'XDG_DESKTOP_PORTAL_PATH': libexecdir / 'xdg-desktop-portal', + 'XDG_PERMISSION_STORE_PATH': libexecdir / 'xdg-permission-store', + 'XDG_DOCUMENT_PORTAL_PATH': libexecdir / 'xdg-document-portal', + 'XDP_VALIDATE_ICON': libexecdir / 'xdg-desktop-portal-validate-icon', + 'XDP_VALIDATE_SOUND': libexecdir / 'xdg-desktop-portal-validate-sound', + } + env = '' + foreach key, value : installed_env + env += f'@key@=@value@ ' + endforeach + + foreach pytest_file : pytest_files + testname = pytest_file.replace('.py', '') + + exec = [pytest.full_path(), installed_tests_dir / 'tests'] + pytest_args + ['-k', testname] + exec = ' '.join(exec) + + data = configuration_data() + data.set('exec', exec) + data.set('env', env) + data.set('libdir', libdir) + + configure_file( + input: 'template.test.in', + output: '@0@.test'.format(testname), + configuration: data, + install: true, + install_dir: installed_tests_data_dir, + ) + endforeach + endif endif if enable_installed_tests @@ -352,9 +421,9 @@ if enable_installed_tests ] foreach tf : testfiles data = configuration_data() - data.set('installed_testdir', installed_tests_dir) + data.set('exec', installed_tests_dir / tf) + data.set('env', '') data.set('libdir', libdir) - data.set('exec', tf) configure_file( input: 'template.test.in', output: '@0@.test'.format(tf), @@ -366,9 +435,9 @@ if enable_installed_tests foreach p : portal_tests data = configuration_data() - data.set('installed_testdir', installed_tests_dir) + data.set('exec', '@0@ -p /portal/@1@'.format(installed_tests_dir / 'test-portals', p)) + data.set('env', '') data.set('libdir', libdir) - data.set('exec', 'test-portals -p /portal/@0@'.format(p)) configure_file( input: 'template.test.in', output: 'test-portals-@0@.test'.format(p), @@ -380,9 +449,9 @@ if enable_installed_tests foreach p : portal_limited data = configuration_data() - data.set('installed_testdir', installed_tests_dir) + data.set('exec', '@0@ -p /limited/@1@'.format(installed_tests_dir / 'limited-portals', p)) + data.set('env', '') data.set('libdir', libdir) - data.set('exec', 'limited-portals -p /limited/@0@'.format(p)) configure_file( input: 'template.test.in', output: 'test-limited-@0@.test'.format(p), diff --git a/tests/template.test.in b/tests/template.test.in index 475845910..f0696d473 100644 --- a/tests/template.test.in +++ b/tests/template.test.in @@ -1,4 +1,4 @@ [Test] Type=session -Exec=env LSAN_OPTIONS=exitcode=0 LD_LIBRARY_PATH=@libdir@:$LD_LIBRARY_PATH @installed_testdir@/@exec@ --tap +Exec=env LSAN_OPTIONS=exitcode=0 LD_LIBRARY_PATH=@libdir@:$LD_LIBRARY_PATH @env@ @exec@ --tap Output=TAP