test: add build configs for catch2

This commit is contained in:
Aleksei Bavshin 2021-08-13 18:33:24 -07:00
parent 1f16d7955d
commit 6eba62f060
No known key found for this signature in database
GPG Key ID: 4F071603387A382A
5 changed files with 47 additions and 0 deletions

View File

@ -360,6 +360,15 @@ if scdoc.found()
endforeach endforeach
endif endif
catch2 = dependency(
'catch2',
fallback: ['catch2', 'catch2_dep'],
required: get_option('tests'),
)
if catch2.found()
subdir('test')
endif
clangtidy = find_program('clang-tidy', required: false) clangtidy = find_program('clang-tidy', required: false)
if clangtidy.found() if clangtidy.found()

View File

@ -10,3 +10,4 @@ option('mpd', type: 'feature', value: 'auto', description: 'Enable support for t
option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support') option('gtk-layer-shell', type: 'feature', value: 'auto', description: 'Use gtk-layer-shell library for popups support')
option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL') option('rfkill', type: 'feature', value: 'auto', description: 'Enable support for RFKILL')
option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio') option('sndio', type: 'feature', value: 'auto', description: 'Enable support for sndio')
option('tests', type: 'feature', value: 'auto', description: 'Enable tests')

12
subprojects/catch2.wrap Normal file
View File

@ -0,0 +1,12 @@
[wrap-file]
directory = Catch2-2.13.3
source_url = https://github.com/catchorg/Catch2/archive/v2.13.3.zip
source_filename = Catch2-2.13.3.zip
source_hash = 1804feb72bc15c0856b4a43aa586c661af9c3685a75973b6a8fc0b950c7cfd13
patch_url = https://github.com/mesonbuild/catch2/releases/download/2.13.3-2/catch2.zip
patch_filename = catch2-2.13.3-2-wrap.zip
patch_hash = 21b590ab8c65b593ad5ee8f8e5b822bf9877b2c2672f97fbb52459751053eadf
[provide]
catch2 = catch2_dep

4
test/config.cpp Normal file
View File

@ -0,0 +1,4 @@
#define CATCH_CONFIG_MAIN
#include "config.hpp"
#include <catch2/catch.hpp>

21
test/meson.build Normal file
View File

@ -0,0 +1,21 @@
test_inc = include_directories('../include')
test_dep = [
catch2,
fmt,
jsoncpp,
spdlog,
]
config_test = executable(
'config_test',
'config.cpp',
'../src/config.cpp',
dependencies: test_dep,
include_directories: test_inc,
)
test(
'Configuration test',
config_test,
workdir: meson.source_root(),
)