diff options
author | kcgen <kcgen@users.noreply.github.com> | 2022-08-07 21:59:49 +0300 |
---|---|---|
committer | kcgen <kcgen@users.noreply.github.com> | 2022-08-07 21:59:49 +0300 |
commit | c40a6cd98f1654e94d35c5c22d70a7e0668fb134 (patch) | |
tree | 0eedd8dbc746c253b4d33083078108d6b88b214c | |
parent | 4ebdd316ccbc5fcdaa9f72ef5f9a22dcdccb7ca4 (diff) |
Move meson test to top-level and use in iir1kc/top-level-unit-tests-1
-rw-r--r-- | meson.build | 15 | ||||
-rw-r--r-- | tests/meson.build | 54 |
2 files changed, 34 insertions, 35 deletions
diff --git a/meson.build b/meson.build index f72fe33f1..434b0b271 100644 --- a/meson.build +++ b/meson.build @@ -309,11 +309,20 @@ threads_dep = dependency('threads') static_libs_list = get_option('try_static_libs') system_libs_list = get_option('use_system_libs') +wants_tests = true +# tests are disabled for release builds unless requested +if get_option('buildtype') == 'release' and get_option('unit_tests').auto() + wants_tests = false +elif get_option('unit_tests').disabled() + wants_tests = false +endif + libiir_dep = dependency( 'iir', version: '>= 1.9.3', default_options: [ 'default_library=static', + 'tests=' + wants_tests.to_string(), 'warning_level=0', ], allow_fallback: ('iir' not in system_libs_list), @@ -675,5 +684,7 @@ dosbox_dep = declare_dependency(link_with: libdosbox) # Some tests use relative paths; in meson 0.56.0 this can be replaced # with meson.project_source_root(). # -project_source_root = meson.current_source_dir() -subdir('tests') +if wants_tests + project_source_root = meson.current_source_dir() + subdir('tests') +endif diff --git a/tests/meson.build b/tests/meson.build index 8644bd5c0..d00f51283 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,8 +1,5 @@ # gtest dependency # -# 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 gmock and gtest via pkg-config; # if this fails, it will download wrap dependency (subproject). # @@ -12,26 +9,17 @@ # # If gmock and gtest are not available at all, unit tests will be disabled. # -gmock_dep = disabler() -if ( - not ( - get_option('buildtype') == 'release' - and get_option('unit_tests').auto() - ) +# Depend on gmock > 1.8.0 pulling in gtest as a dependency, otherwise it's hard +# to set up gtest and gmock in mixed wrap/system-installed edge-cases. +gmock_dep = dependency( + 'gmock', + main: true, + version: '> 1.8.0', + disabler: true, + required: get_option('unit_tests'), + fallback: ['gtest', 'gmock_main_dep'], ) - # Depend on gmock > 1.8.0 pulling in gtest as a dependency, otherwise it's hard - # to set up gtest and gmock in mixed wrap/system-installed edge-cases. - gmock_dep = dependency( - 'gmock', - main: true, - version: '> 1.8.0', - disabler: true, - required: get_option('unit_tests'), - fallback: ['gtest', 'gmock_main_dep'], - ) -endif - summary('Unit tests', gmock_dep.found()) # Disable compiler flags that generate warnings @@ -78,18 +66,18 @@ test( # other unit tests unit_tests = [ - {'name' : 'bitops', 'deps' : []}, - {'name' : 'bit_view', 'deps' : []}, - {'name' : 'iohandler_containers', 'deps' : [libmisc_dep]}, - {'name' : 'rwqueue', 'deps' : [libmisc_dep]}, - {'name' : 'string_utils', 'deps' : []}, - {'name' : 'setup', 'deps' : [libmisc_dep]}, - {'name' : 'support', 'deps' : [libmisc_dep]}, - {'name' : 'drives', 'deps' : [dosbox_dep], 'extra_cpp': []}, - {'name' : 'dos_files', 'deps' : [dosbox_dep], 'extra_cpp': []}, - {'name' : 'shell_cmds', 'deps' : [dosbox_dep], 'extra_cpp': []}, - {'name' : 'shell_redirection', 'deps' : [dosbox_dep], 'extra_cpp': []}, - {'name' : 'ansi_code_markup', 'deps' : [libmisc_dep]}, + {'name': 'bitops', 'deps': []}, + {'name': 'bit_view', 'deps': []}, + {'name': 'iohandler_containers', 'deps': [libmisc_dep]}, + {'name': 'rwqueue', 'deps': [libmisc_dep]}, + {'name': 'string_utils', 'deps': []}, + {'name': 'setup', 'deps': [libmisc_dep]}, + {'name': 'support', 'deps': [libmisc_dep]}, + {'name': 'drives', 'deps': [dosbox_dep], 'extra_cpp': []}, + {'name': 'dos_files', 'deps': [dosbox_dep], 'extra_cpp': []}, + {'name': 'shell_cmds', 'deps': [dosbox_dep], 'extra_cpp': []}, + {'name': 'shell_redirection', 'deps': [dosbox_dep], 'extra_cpp': []}, + {'name': 'ansi_code_markup', 'deps': [libmisc_dep]}, ] extra_link_flags = [] |