blob: 8e17d71a77417d0278b56c62978dbfbf87044f92 [file] [log] [blame]
William A. Kennington III245495e2020-02-13 13:07:30 -08001gtests = [
William A. Kennington III458aeae2021-06-14 15:07:16 -07002 'cancel',
William A. Kennington III9a70f4e2021-05-01 17:16:57 -07003 'exception',
William A. Kennington IIIe847ef82018-11-02 17:29:15 -07004 'handle/copyable',
William A. Kennington III7a5e2322018-11-02 17:28:35 -07005 'handle/managed',
William A. Kennington III0bd13702022-08-24 13:33:34 -07006 'signal',
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -08007 'util/cexec',
William A. Kennington III4ef36e72019-06-27 12:48:59 -07008 'util/string',
William A. Kennington III15982f62019-01-31 14:43:41 -08009]
10
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070011gtest_deps = [
12 stdplus_dep,
William A. Kennington III953de362022-07-13 17:32:55 -070013 gtest_main_dep,
14 gmock_dep,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070015]
16
William A. Kennington III5a528022021-04-28 12:52:43 -070017if has_dl
18 gtests += [
19 'dl',
20 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070021
22 gtest_deps += [
23 stdplus_dl_dep,
24 ]
William A. Kennington III5a528022021-04-28 12:52:43 -070025elif build_tests.enabled()
26 error('Not testing libdl feature')
27else
28 warning('Not testing libdl feature')
29endif
30
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070031if has_fd
32 gtests += [
33 'fd/dupable',
34 'fd/managed',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070035 'fd/fmt',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070036 'fd/intf',
37 'fd/impl',
William A. Kennington III9a512c92022-08-12 15:15:55 -070038 'fd/line',
William A. Kennington III891e6a32022-05-17 16:35:03 -070039 'fd/mmap',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070040 'fd/mock',
41 'fd/ops',
42 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070043
44 gtest_deps += [
45 stdplus_fd_dep,
46 ]
William A. Kennington III45754242021-04-28 12:48:31 -070047elif build_tests.enabled()
48 error('Not testing file descriptor feature')
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070049else
50 warning('Not testing file descriptor feature')
51endif
52
William A. Kennington III5c20da22021-06-18 16:44:55 -070053if has_io_uring
54 gtests += [
55 'io_uring',
56 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070057
58 gtest_deps += [
59 stdplus_io_uring_dep,
60 ]
William A. Kennington III5c20da22021-06-18 16:44:55 -070061elif build_tests.enabled()
62 error('Not testing io_uring feature')
63else
64 warning('Not testing io_uring feature')
65endif
66
William A. Kennington III953de362022-07-13 17:32:55 -070067if has_gtest
68 gtests += [
69 'gtest/tmp',
70 ]
71
72 gtest_deps += [
73 stdplus_gtest_dep,
74 ]
75elif build_tests.enabled()
76 error('Not testing gtest lib feature')
77else
78 warning('Not testing gtest lib feature')
79endif
80
81if gtest_dep.found() and gmock_dep.found()
William A. Kennington III83af3fa2021-01-31 15:22:54 -080082 foreach t : gtests
William A. Kennington III953de362022-07-13 17:32:55 -070083 test(
84 t,
William A. Kennington III2030ea52022-07-19 17:06:39 -070085 run_with_tmp,
William A. Kennington III953de362022-07-13 17:32:55 -070086 env: {'TMPTMPL': 'stdplus-test.XXXXXXXXXX'},
87 args: executable(
88 t.underscorify(), t + '.cpp',
89 build_by_default: false,
90 implicit_include_directories: false,
91 dependencies: gtest_deps))
William A. Kennington III83af3fa2021-01-31 15:22:54 -080092 endforeach
93endif
William A. Kennington III245495e2020-02-13 13:07:30 -080094
William A. Kennington III01db6622021-01-31 15:24:13 -080095# Switch to `catch2-with-main.pc` when 2.x supports it
96catch2 = dependency('catch2-with-main', required: false)
97if not catch2.found()
98 catch2 = dependency('catch2', required: false)
99 if catch2.found()
100 catch2_main = meson.get_compiler('cpp').find_library(
101 'Catch2WithMain', required: false)
102 if catch2_main.found()
103 catch2 = declare_dependency(
104 dependencies: [
105 catch2,
106 catch2_main,
107 ])
108 else
109 catch2 = declare_dependency(
110 link_with: static_library(
111 'catch2', 'catch2_main.cpp',
112 implicit_include_directories: false,
113 build_by_default: false,
114 dependencies: catch2),
115 dependencies: catch2)
116 endif
117 endif
118endif
119if not catch2.found()
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700120 catch2_opts = import('cmake').subproject_options()
121 catch2_opts.add_cmake_defines({
122 'BUILD_TESTING': 'OFF',
123 'CMAKE_CXX_FLAGS': '-Wno-non-virtual-dtor',
124 })
William A. Kennington III245495e2020-02-13 13:07:30 -0800125 catch2_proj = import('cmake').subproject(
126 'Catch2',
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700127 options: catch2_opts,
William A. Kennington III245495e2020-02-13 13:07:30 -0800128 required: false)
129 if catch2_proj.found()
William A. Kennington III01db6622021-01-31 15:24:13 -0800130 catch2 = declare_dependency(
131 dependencies: [
132 catch2_proj.dependency('Catch2'),
133 catch2_proj.dependency('Catch2WithMain'),
134 ])
William A. Kennington III245495e2020-02-13 13:07:30 -0800135 else
136 assert(not build_tests.enabled(), 'Catch2 is required')
137 endif
138endif
139
140catch2_tests = [
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700141 'raw',
William A. Kennington III245495e2020-02-13 13:07:30 -0800142]
143
William A. Kennington III01db6622021-01-31 15:24:13 -0800144if catch2.found()
William A. Kennington III245495e2020-02-13 13:07:30 -0800145 foreach t : catch2_tests
146 test(t, executable(t.underscorify(), t + '.cpp',
William A. Kennington III31422352020-02-19 13:21:56 -0800147 build_by_default: false,
William A. Kennington III245495e2020-02-13 13:07:30 -0800148 implicit_include_directories: false,
William A. Kennington III3acf92b2021-04-16 13:33:50 -0700149 dependencies: [stdplus_dep, catch2]))
William A. Kennington III245495e2020-02-13 13:07:30 -0800150 endforeach
151endif