diff options
author | Patryk Obara <dreamer.tan@gmail.com> | 2022-02-15 06:54:04 +0300 |
---|---|---|
committer | Patryk Obara <dreamer.tan@gmail.com> | 2022-02-15 06:54:04 +0300 |
commit | 492bd0db8d55c913d41d231ef42058c323642428 (patch) | |
tree | 690161f570c125473251d7a909130da6398d2650 | |
parent | 15e106100fdf3a29c1e74ea0635f51164e4710b1 (diff) |
fixup! Assure gtest and gmock in the same versionpo/fix-gmock-detection
-rw-r--r-- | BUILD.md | 4 | ||||
-rw-r--r-- | tests/meson.build | 41 |
2 files changed, 13 insertions, 32 deletions
@@ -135,9 +135,9 @@ sudo dnf install gmock-devel gtest-devel ``` ``` shell # Debian, Ubuntu -sudo apt install libgtest-dev +sudo apt install libgtest-dev libgmock-dev ``` -If `gtest` is not available/installed on the OS, Meson will download it +If GTest/GMock is not available/installed on the OS, Meson will download it automatically. Build and run tests: diff --git a/tests/meson.build b/tests/meson.build index 047db87c0..a94534560 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -3,47 +3,28 @@ # If feature 'unit_tests' is set to 'auto', then unit tests are disabled # for release builds and enabled everywhere else. # -# Meson will first try to find pre-installed gtest via pkg-config; +# Meson will first try to find pre-installed gmock and gtest via pkg-config; # if this fails, it will download wrap dependency (subproject). # # Users can further configure the download behaviour using: # # meson setup --wrap-mode={nofallback,nodownload,forcefallback} # -# If gtest is not available at all, unit tests will be disabled. +# If gmock and gtest are not available at all, unit tests will be disabled. # -gtest_dep = optional_dep gmock_dep = optional_dep if not (get_option('buildtype') == 'release' and get_option('unit_tests').auto()) - gtest_system_dep = dependency('gtest', main : true, - required : get_option('unit_tests')) - gmock_system_dep = dependency('gmock', main : true, - required : get_option('unit_tests')) - - # GTest and GMock are closely coupled together, we must use them in exactly - # the same version. We can't allow situation when one of packages is - # system-installed and another one is used from meson subproject. - # - if (gmock_system_dep.found() and gtest_system_dep.found()) - gtest_dep = gtest_system_dep - gmock_dep = gmock_system_dep - else - message('GTest or GMock is not installed, using fallback for both dependencies') - gtest_dep = dependency('', main : true, - required : get_option('unit_tests'), - fallback : ['gtest', 'gtest_main_dep']) - gmock_dep = dependency('', main : true, - required : get_option('unit_tests'), - fallback : ['gtest', 'gmock_dep']) - endif + gmock_dep = dependency('gmock', main : true, + version : '> 1.8.0', + required : get_option('unit_tests'), + fallback : ['gtest', 'gmock_main_dep']) endif -if not (gtest_dep.found() and gmock_dep.found()) - gtest_dep = disabler() +if not gmock_dep.found() gmock_dep = disabler() endif -summary('Unit tests', gtest_dep.found() and gmock_dep.found()) +summary('Unit tests', gmock_dep.found()) # Disable compiler flags that generate warnings # from deliberately flawed unit test code. @@ -61,13 +42,13 @@ endforeach # - fs_utils - depends on files in: tests/files/ # example = executable('example', ['example_tests.cpp', 'stubs.cpp'], - dependencies : [gmock_dep, gtest_dep, libmisc_dep, libghc_dep, libloguru_dep], + dependencies : [gmock_dep, libmisc_dep, libghc_dep, libloguru_dep], include_directories : incdir, cpp_args : cpp_args) test('gtest example', example, should_fail : true) fs_utils = executable('fs_utils', ['fs_utils_tests.cpp', 'stubs.cpp'], - dependencies : [gmock_dep, gtest_dep, libmisc_dep, libghc_dep, libloguru_dep], + dependencies : [gmock_dep, libmisc_dep, libghc_dep, libloguru_dep], include_directories : incdir, cpp_args : cpp_args) test('gtest fs_utils', fs_utils, workdir : project_source_root, is_parallel : false) @@ -93,7 +74,7 @@ foreach ut : unit_tests name = ut.get('name') extra_cpp = ut.get('extra_cpp', ['stubs.cpp']) exe = executable(name, [name + '_tests.cpp'] + extra_cpp, - dependencies : [gmock_dep, gtest_dep, libghc_dep, libloguru_dep] + ut.get('deps'), + dependencies : [gmock_dep, libghc_dep, libloguru_dep] + ut.get('deps'), include_directories : incdir, cpp_args : cpp_args) test('gtest ' + name, exe) endforeach |