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