diff options
author | Qyriad <qyriad@qyriad.me> | 2024-03-21 15:38:11 -0600 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-03-26 00:43:33 +0100 |
commit | e1ffe56793be79dfea203121ecafff3d0baa29ba (patch) | |
tree | d337477251bc4187820ba0388c63e1c4d6a9c5f5 /meson.build | |
parent | d3d7489571baeb651d3843dba3b638621694c174 (diff) |
meson: implement unit tests
Unit tests can be run with `meson test -C build --suite check`.
`--suite check` is optional, as right now that's the only test suite,
but when functional tests are added those will be in a separate suite.
Change-Id: I7f22f1cde4b489b3cdb5f9a36a544f0c409fcc1f
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/meson.build b/meson.build index 73c13582b..66a30f716 100644 --- a/meson.build +++ b/meson.build @@ -16,6 +16,8 @@ # that become part of the final Nix command (things like `src/nix-build/*.cc`). # # Finally, src/nix/meson.build defines the Nix command itself, relying on all prior meson files. +# +# Unit tests are setup in tests/unit/meson.build, under the test suite "check". project('lix', 'cpp', version : run_command('bash', '-c', 'echo -n $(cat ./.version)$VERSION_SUFFIX', check : true).stdout().strip(), @@ -56,6 +58,20 @@ foreach optname : path_opts endif endforeach + +enable_tests = get_option('enable-tests') + +tests_args = [] + +if get_option('tests-color') + tests_args += '--gtest_color=yes' +endif + +if get_option('tests-brief') + tests_args += '--gtest_brief=1' +endif + + cxx = meson.get_compiler('cpp') host_system = host_machine.cpu_family() + '-' + host_machine.system() @@ -170,10 +186,17 @@ deps += editline lowdown = dependency('lowdown', version : '>=0.9.0', required : true) deps += lowdown -rapidcheck = dependency('rapidcheck', required : false) +# HACK(Qyriad): rapidcheck's pkg-config doesn't include the libs lol +rapidcheck_meson = dependency('rapidcheck', required : enable_tests) +rapidcheck = declare_dependency(dependencies : rapidcheck_meson, link_args : ['-lrapidcheck']) deps += rapidcheck -gtest = dependency('gtest', required : false) +gtest = [ + dependency('gtest', required : enable_tests), + dependency('gtest_main', required : enable_tests), + dependency('gmock', required : enable_tests), + dependency('gmock_main', required : enable_tests), +] deps += gtest # @@ -285,3 +308,6 @@ if cxx.get_linker_id() in ['ld.bfd', 'ld.gold'] endif subdir('src') +if enable_tests + subdir('tests/unit') +endif |