Skip to content

Commit

Permalink
meson: Add option to control tests
Browse files Browse the repository at this point in the history
By using a meson feature type option, the default behavior is to run all
tests possible. However, packagers have more control on whether they
want tests to run, including Linux distro who have frameworks for
controlling these options.
  • Loading branch information
dcbaker committed Mar 9, 2024
1 parent ef30d6a commit da1c854
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ninja -C builddir test

Running the functional tests requires Python >= 3.11

Meson currently is configured with support to build all of it's dependencies
from source if they are not otherwise detected, by fetching at configure time.
Meson currently is configured with support to build all of its dependencies
from source if they are not otherwise detected by fetching them at configure time.
If this is not desirable, calling:

```sh
Expand All @@ -27,6 +27,19 @@ meson setup builddir --wrap-mode=nofallback
Will disable this behavior. This will require that all dependencies have been
installed and are discoverable at configure time.

Test execution can be controlled by setting the `test` option to Meson:
```sh
meson setup builddir -Dtests=disabled
```
Or, alternatively, to enable tests:
```sh
meson configure builddir -Dtests=enabled
```
This is a Meson [feature](https://mesonbuild.com/Build-options.html#features)
option, which can have a state of `disabled`, `enabled`, or `auto`, as described
in the linked documentation. The default is `auto`, which is usually desirable
for end users.

## Status

CPS-config is currently in alpha status. Some things work, others do not.
Expand Down
5 changes: 3 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ cps_config = executable(
install : true,
)

build_tests = get_option('tests')

test(
'pkg-config compatibility',
find_program('python', version : '>=3.11', required : false, disabler : true),
find_program('python', version : '>=3.11', required : build_tests, disabler : true),
args: [files('tests/runner.py'), cps_config, 'tests/cases.toml'],
protocol : 'tap',
env : {'CPS_PATH' : meson.current_source_dir() / 'tests' / 'cases' },
)

dep_gtest = dependency('gtest_main', required : false, disabler : true, allow_fallback : true)
dep_gtest = dependency('gtest_main', required : build_tests, disabler : true, allow_fallback : true)

foreach t : ['version', 'utils']
test(
Expand Down
8 changes: 8 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: MIT
# Copyright © 2024 Dylan Baker

option(
'tests',
type : 'feature',
description : 'Build and run tests',
)

0 comments on commit da1c854

Please sign in to comment.