blob: 4ffd1a9568cb24638772e6aadaf12a7333468f29 [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 IIIbff0b0f2018-11-16 19:56:10 -08006 'util/cexec',
William A. Kennington III4ef36e72019-06-27 12:48:59 -07007 'util/string',
William A. Kennington III15982f62019-01-31 14:43:41 -08008]
9
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070010gtest_deps = [
11 stdplus_dep,
William A. Kennington III953de362022-07-13 17:32:55 -070012 gtest_main_dep,
13 gmock_dep,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070014]
15
William A. Kennington III5a528022021-04-28 12:52:43 -070016if has_dl
17 gtests += [
18 'dl',
19 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070020
21 gtest_deps += [
22 stdplus_dl_dep,
23 ]
William A. Kennington III5a528022021-04-28 12:52:43 -070024elif build_tests.enabled()
25 error('Not testing libdl feature')
26else
27 warning('Not testing libdl feature')
28endif
29
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070030if has_fd
31 gtests += [
32 'fd/dupable',
33 'fd/managed',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070034 'fd/fmt',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070035 'fd/intf',
36 'fd/impl',
William A. Kennington III9a512c92022-08-12 15:15:55 -070037 'fd/line',
William A. Kennington III891e6a32022-05-17 16:35:03 -070038 'fd/mmap',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070039 'fd/mock',
40 'fd/ops',
41 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070042
43 gtest_deps += [
44 stdplus_fd_dep,
45 ]
William A. Kennington III45754242021-04-28 12:48:31 -070046elif build_tests.enabled()
47 error('Not testing file descriptor feature')
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070048else
49 warning('Not testing file descriptor feature')
50endif
51
William A. Kennington III5c20da22021-06-18 16:44:55 -070052if has_io_uring
53 gtests += [
54 'io_uring',
55 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070056
57 gtest_deps += [
58 stdplus_io_uring_dep,
59 ]
William A. Kennington III5c20da22021-06-18 16:44:55 -070060elif build_tests.enabled()
61 error('Not testing io_uring feature')
62else
63 warning('Not testing io_uring feature')
64endif
65
William A. Kennington III953de362022-07-13 17:32:55 -070066if has_gtest
67 gtests += [
68 'gtest/tmp',
69 ]
70
71 gtest_deps += [
72 stdplus_gtest_dep,
73 ]
74elif build_tests.enabled()
75 error('Not testing gtest lib feature')
76else
77 warning('Not testing gtest lib feature')
78endif
79
80if gtest_dep.found() and gmock_dep.found()
William A. Kennington III83af3fa2021-01-31 15:22:54 -080081 foreach t : gtests
William A. Kennington III953de362022-07-13 17:32:55 -070082 test(
83 t,
William A. Kennington III2030ea52022-07-19 17:06:39 -070084 run_with_tmp,
William A. Kennington III953de362022-07-13 17:32:55 -070085 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 III83af3fa2021-01-31 15:22:54 -080091 endforeach
92endif
William A. Kennington III245495e2020-02-13 13:07:30 -080093
William A. Kennington III01db6622021-01-31 15:24:13 -080094# Switch to `catch2-with-main.pc` when 2.x supports it
95catch2 = dependency('catch2-with-main', required: false)
96if 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
117endif
118if not catch2.found()
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700119 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 III245495e2020-02-13 13:07:30 -0800124 catch2_proj = import('cmake').subproject(
125 'Catch2',
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700126 options: catch2_opts,
William A. Kennington III245495e2020-02-13 13:07:30 -0800127 required: false)
128 if catch2_proj.found()
William A. Kennington III01db6622021-01-31 15:24:13 -0800129 catch2 = declare_dependency(
130 dependencies: [
131 catch2_proj.dependency('Catch2'),
132 catch2_proj.dependency('Catch2WithMain'),
133 ])
William A. Kennington III245495e2020-02-13 13:07:30 -0800134 else
135 assert(not build_tests.enabled(), 'Catch2 is required')
136 endif
137endif
138
139catch2_tests = [
William A. Kennington III770c5562020-02-13 13:07:42 -0800140 'signal',
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