1gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
2gmock_dep = dependency('gmock', disabler: true, required: false)
3if not gtest_dep.found() or not gmock_dep.found()
4    gtest_proj = import('cmake').subproject('googletest', required: false)
5    if gtest_proj.found()
6        gtest_dep = declare_dependency(
7            dependencies: [
8                dependency('threads'),
9                gtest_proj.dependency('gtest'),
10                gtest_proj.dependency('gtest_main'),
11            ]
12        )
13        gmock_dep = gtest_proj.dependency('gmock')
14  else
15        assert(
16            not get_option('tests').allowed(),
17            'Googletest is required if tests are enabled'
18        )
19  endif
20endif
21
22test_sources = [
23  '../manager/manager.cpp',
24  '../utils.cpp'
25]
26
27tests = [
28  'utest.cpp',
29  'utest-led-json.cpp',
30]
31if get_option('persistent-led-asserted').allowed()
32  test_sources += [
33    '../manager/serialize.cpp',
34  ]
35  tests += [
36    'utest-serialize.cpp',
37  ]
38endif
39
40foreach t : tests
41  test(t, executable(t.underscorify(), t,
42                     test_sources,
43                     include_directories: ['..', '../manager'],
44                     dependencies: [
45                         gtest_dep,
46                         gmock_dep,
47                         deps
48                         ]),
49       workdir: meson.current_source_dir())
50endforeach
51