Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson: Allow tests to be optional #692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ if get_option('stemming')
endif
endif

if get_option('installed_tests') and not get_option('tests')
error('-Dinstalled_tests=true is incompatible with -Dtests=false')
endif

# use gperf for faster string -> enum matching
gperf = find_program('gperf')

Expand All @@ -227,7 +231,9 @@ subdir('po/')
subdir('data/')
subdir('contrib/')
subdir('docs/')
subdir('tests/')
if get_option('tests')
subdir('tests/')
endif
if get_option('qt')
subdir('qt/')
endif
10 changes: 10 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ option('install-docs',
value : true,
description : 'Install documentation for API and specification'
)
option('tests',
description: 'Build the test suite',
type: 'boolean',
value: true
)
Comment on lines +68 to +72

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are always optional, you never have to run them. What's the goal here? Just to avoid compiling the test programs by default?

I would suggest instead setting build_by_default: false for test progs. Meson 1.7 won't build them by default anymore, if you do so.

Copy link
Author

@bbhtt bbhtt Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

1.7 is too new for me to benefit from it and still only rc

option('installed_tests',
description: 'Install the test suite',
type: 'boolean',
value: true
)

#
# For development
Expand Down
4 changes: 3 additions & 1 deletion tests/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Meson definition for AppStream Tests

subdir('installed-tests/')
if get_option('installed_tests')
subdir('installed-tests/')
endif

as_test_env = []
as_test_args = [meson.current_source_dir()]
Expand Down