William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 1 | gtests = [ |
William A. Kennington III | 458aeae | 2021-06-14 15:07:16 -0700 | [diff] [blame] | 2 | 'cancel', |
William A. Kennington III | 9a70f4e | 2021-05-01 17:16:57 -0700 | [diff] [blame] | 3 | 'exception', |
William A. Kennington III | e847ef8 | 2018-11-02 17:29:15 -0700 | [diff] [blame] | 4 | 'handle/copyable', |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 5 | 'handle/managed', |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 6 | 'util/cexec', |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 7 | 'util/string', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 8 | ] |
| 9 | |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 10 | gtest_deps = [ |
| 11 | stdplus_dep, |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 12 | gtest_main_dep, |
| 13 | gmock_dep, |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 14 | ] |
| 15 | |
William A. Kennington III | 5a52802 | 2021-04-28 12:52:43 -0700 | [diff] [blame] | 16 | if has_dl |
| 17 | gtests += [ |
| 18 | 'dl', |
| 19 | ] |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 20 | |
| 21 | gtest_deps += [ |
| 22 | stdplus_dl_dep, |
| 23 | ] |
William A. Kennington III | 5a52802 | 2021-04-28 12:52:43 -0700 | [diff] [blame] | 24 | elif build_tests.enabled() |
| 25 | error('Not testing libdl feature') |
| 26 | else |
| 27 | warning('Not testing libdl feature') |
| 28 | endif |
| 29 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 30 | if has_fd |
| 31 | gtests += [ |
| 32 | 'fd/dupable', |
| 33 | 'fd/managed', |
William A. Kennington III | 4f5711c | 2022-08-12 17:01:53 -0700 | [diff] [blame] | 34 | 'fd/fmt', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 35 | 'fd/intf', |
| 36 | 'fd/impl', |
William A. Kennington III | 9a512c9 | 2022-08-12 15:15:55 -0700 | [diff] [blame] | 37 | 'fd/line', |
William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame] | 38 | 'fd/mmap', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 39 | 'fd/mock', |
| 40 | 'fd/ops', |
| 41 | ] |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 42 | |
| 43 | gtest_deps += [ |
| 44 | stdplus_fd_dep, |
| 45 | ] |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 46 | elif build_tests.enabled() |
| 47 | error('Not testing file descriptor feature') |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 48 | else |
| 49 | warning('Not testing file descriptor feature') |
| 50 | endif |
| 51 | |
William A. Kennington III | 5c20da2 | 2021-06-18 16:44:55 -0700 | [diff] [blame] | 52 | if has_io_uring |
| 53 | gtests += [ |
| 54 | 'io_uring', |
| 55 | ] |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 56 | |
| 57 | gtest_deps += [ |
| 58 | stdplus_io_uring_dep, |
| 59 | ] |
William A. Kennington III | 5c20da2 | 2021-06-18 16:44:55 -0700 | [diff] [blame] | 60 | elif build_tests.enabled() |
| 61 | error('Not testing io_uring feature') |
| 62 | else |
| 63 | warning('Not testing io_uring feature') |
| 64 | endif |
| 65 | |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 66 | if has_gtest |
| 67 | gtests += [ |
| 68 | 'gtest/tmp', |
| 69 | ] |
| 70 | |
| 71 | gtest_deps += [ |
| 72 | stdplus_gtest_dep, |
| 73 | ] |
| 74 | elif build_tests.enabled() |
| 75 | error('Not testing gtest lib feature') |
| 76 | else |
| 77 | warning('Not testing gtest lib feature') |
| 78 | endif |
| 79 | |
| 80 | if gtest_dep.found() and gmock_dep.found() |
William A. Kennington III | 83af3fa | 2021-01-31 15:22:54 -0800 | [diff] [blame] | 81 | foreach t : gtests |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 82 | test( |
| 83 | t, |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 84 | run_with_tmp, |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 85 | env: {'TMPTMPL': 'stdplus-test.XXXXXXXXXX'}, |
| 86 | args: executable( |
| 87 | t.underscorify(), t + '.cpp', |
| 88 | build_by_default: false, |
| 89 | implicit_include_directories: false, |
| 90 | dependencies: gtest_deps)) |
William A. Kennington III | 83af3fa | 2021-01-31 15:22:54 -0800 | [diff] [blame] | 91 | endforeach |
| 92 | endif |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 93 | |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 94 | # Switch to `catch2-with-main.pc` when 2.x supports it |
| 95 | catch2 = dependency('catch2-with-main', required: false) |
| 96 | if not catch2.found() |
| 97 | catch2 = dependency('catch2', required: false) |
| 98 | if catch2.found() |
| 99 | catch2_main = meson.get_compiler('cpp').find_library( |
| 100 | 'Catch2WithMain', required: false) |
| 101 | if catch2_main.found() |
| 102 | catch2 = declare_dependency( |
| 103 | dependencies: [ |
| 104 | catch2, |
| 105 | catch2_main, |
| 106 | ]) |
| 107 | else |
| 108 | catch2 = declare_dependency( |
| 109 | link_with: static_library( |
| 110 | 'catch2', 'catch2_main.cpp', |
| 111 | implicit_include_directories: false, |
| 112 | build_by_default: false, |
| 113 | dependencies: catch2), |
| 114 | dependencies: catch2) |
| 115 | endif |
| 116 | endif |
| 117 | endif |
| 118 | if not catch2.found() |
William A. Kennington III | b5d1c58 | 2021-04-16 13:41:39 -0700 | [diff] [blame] | 119 | catch2_opts = import('cmake').subproject_options() |
| 120 | catch2_opts.add_cmake_defines({ |
| 121 | 'BUILD_TESTING': 'OFF', |
| 122 | 'CMAKE_CXX_FLAGS': '-Wno-non-virtual-dtor', |
| 123 | }) |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 124 | catch2_proj = import('cmake').subproject( |
| 125 | 'Catch2', |
William A. Kennington III | b5d1c58 | 2021-04-16 13:41:39 -0700 | [diff] [blame] | 126 | options: catch2_opts, |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 127 | required: false) |
| 128 | if catch2_proj.found() |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 129 | catch2 = declare_dependency( |
| 130 | dependencies: [ |
| 131 | catch2_proj.dependency('Catch2'), |
| 132 | catch2_proj.dependency('Catch2WithMain'), |
| 133 | ]) |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 134 | else |
| 135 | assert(not build_tests.enabled(), 'Catch2 is required') |
| 136 | endif |
| 137 | endif |
| 138 | |
| 139 | catch2_tests = [ |
William A. Kennington III | 770c556 | 2020-02-13 13:07:42 -0800 | [diff] [blame] | 140 | 'signal', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 141 | 'raw', |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 142 | ] |
| 143 | |
William A. Kennington III | 01db662 | 2021-01-31 15:24:13 -0800 | [diff] [blame] | 144 | if catch2.found() |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 145 | foreach t : catch2_tests |
| 146 | test(t, executable(t.underscorify(), t + '.cpp', |
William A. Kennington III | 3142235 | 2020-02-19 13:21:56 -0800 | [diff] [blame] | 147 | build_by_default: false, |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 148 | implicit_include_directories: false, |
William A. Kennington III | 3acf92b | 2021-04-16 13:33:50 -0700 | [diff] [blame] | 149 | dependencies: [stdplus_dep, catch2])) |
William A. Kennington III | 245495e | 2020-02-13 13:07:30 -0800 | [diff] [blame] | 150 | endforeach |
| 151 | endif |