Skip to content

Commit

Permalink
Building tests is optional (#122)
Browse files Browse the repository at this point in the history
It's better to base the test-building condition on a command-line option
instead of the presence of Catch2. Building the tests is not necessary
for normal usage of redsea anyway.
  • Loading branch information
windytan committed Jan 1, 2025
1 parent 1600a9f commit d4d5023
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Install dependencies (brew)
run: brew install meson libsndfile liquid-dsp nlohmann-json catch2 perl gcovr
- name: meson setup
run: meson setup -Dwerror=true -Db_sanitize=address,undefined -Db_lundef=false -Db_coverage=true build
run: meson setup -Dwerror=true -Db_sanitize=address,undefined -Db_lundef=false -Db_coverage=true build -Dbuild_tests=true
- name: compile & install
run: cd build && meson install
- name: download test data
Expand Down
8 changes: 5 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(
'prefix=/usr/local',
'cpp_std=c++14',
],
version: '1.1.0',
version: '1.1.1-SNAPSHOT',
)

# Store version number to be compiled in
Expand Down Expand Up @@ -121,9 +121,11 @@ executable(
### Unit tests ###
##################

catch2 = dependency('catch2-with-main', required: false)
build_tests = get_option('build_tests')

if build_tests
catch2 = dependency('catch2-with-main', required: true)

if catch2.found()
unit_test_exe = executable(
'redsea-test-unit',
[
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('build_tests', type: 'boolean', value: false, description: 'Build unit tests (requires Catch2)')

0 comments on commit d4d5023

Please sign in to comment.