blob: 1f284a5542c8c4a1128e1cdeb1dad449b11e787e [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',
34 'fd/intf',
35 'fd/impl',
William A. Kennington III891e6a32022-05-17 16:35:03 -070036 'fd/mmap',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070037 'fd/mock',
38 'fd/ops',
39 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070040
41 gtest_deps += [
42 stdplus_fd_dep,
43 ]
William A. Kennington III45754242021-04-28 12:48:31 -070044elif build_tests.enabled()
45 error('Not testing file descriptor feature')
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070046else
47 warning('Not testing file descriptor feature')
48endif
49
William A. Kennington III5c20da22021-06-18 16:44:55 -070050if has_io_uring
51 gtests += [
52 'io_uring',
53 ]
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070054
55 gtest_deps += [
56 stdplus_io_uring_dep,
57 ]
William A. Kennington III5c20da22021-06-18 16:44:55 -070058elif build_tests.enabled()
59 error('Not testing io_uring feature')
60else
61 warning('Not testing io_uring feature')
62endif
63
William A. Kennington III953de362022-07-13 17:32:55 -070064if has_gtest
65 gtests += [
66 'gtest/tmp',
67 ]
68
69 gtest_deps += [
70 stdplus_gtest_dep,
71 ]
72elif build_tests.enabled()
73 error('Not testing gtest lib feature')
74else
75 warning('Not testing gtest lib feature')
76endif
77
78if gtest_dep.found() and gmock_dep.found()
William A. Kennington III83af3fa2021-01-31 15:22:54 -080079 foreach t : gtests
William A. Kennington III953de362022-07-13 17:32:55 -070080 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 III83af3fa2021-01-31 15:22:54 -080089 endforeach
90endif
William A. Kennington III245495e2020-02-13 13:07:30 -080091
William A. Kennington III01db6622021-01-31 15:24:13 -080092# Switch to `catch2-with-main.pc` when 2.x supports it
93catch2 = dependency('catch2-with-main', required: false)
94if 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
115endif
116if not catch2.found()
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700117 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 III245495e2020-02-13 13:07:30 -0800122 catch2_proj = import('cmake').subproject(
123 'Catch2',
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -0700124 options: catch2_opts,
William A. Kennington III245495e2020-02-13 13:07:30 -0800125 required: false)
126 if catch2_proj.found()
William A. Kennington III01db6622021-01-31 15:24:13 -0800127 catch2 = declare_dependency(
128 dependencies: [
129 catch2_proj.dependency('Catch2'),
130 catch2_proj.dependency('Catch2WithMain'),
131 ])
William A. Kennington III245495e2020-02-13 13:07:30 -0800132 else
133 assert(not build_tests.enabled(), 'Catch2 is required')
134 endif
135endif
136
137catch2_tests = [
William A. Kennington III770c5562020-02-13 13:07:42 -0800138 'signal',
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700139 'raw',
William A. Kennington III245495e2020-02-13 13:07:30 -0800140]
141
William A. Kennington III01db6622021-01-31 15:24:13 -0800142if catch2.found()
William A. Kennington III245495e2020-02-13 13:07:30 -0800143 foreach t : catch2_tests
144 test(t, executable(t.underscorify(), t + '.cpp',
William A. Kennington III31422352020-02-19 13:21:56 -0800145 build_by_default: false,
William A. Kennington III245495e2020-02-13 13:07:30 -0800146 implicit_include_directories: false,
William A. Kennington III3acf92b2021-04-16 13:33:50 -0700147 dependencies: [stdplus_dep, catch2]))
William A. Kennington III245495e2020-02-13 13:07:30 -0800148 endforeach
149endif