George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 1 | gtest_dep = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock_dep = dependency('gmock', disabler: true, required: false) |
| 3 | if 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').enabled(), |
| 17 | 'Googletest is required if tests are enabled' |
| 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 22 | test_sources = [ |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 23 | '../manager/manager.cpp', |
| 24 | '../manager/serialize.cpp', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 25 | '../utils.cpp' |
| 26 | ] |
| 27 | |
| 28 | tests = [ |
| 29 | 'utest.cpp', |
| 30 | 'utest-serialize.cpp', |
George Liu | fb00eeb | 2021-06-15 10:04:17 +0800 | [diff] [blame] | 31 | 'utest-led-json.cpp', |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 32 | ] |
| 33 | |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 34 | foreach t : tests |
| 35 | test(t, executable(t.underscorify(), t, |
| 36 | test_sources, |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 37 | include_directories: ['..', '../manager'], |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 38 | dependencies: [ |
George Liu | 687fe07 | 2021-05-04 16:16:43 +0800 | [diff] [blame] | 39 | gtest_dep, |
| 40 | gmock_dep, |
George Liu | 4b06201 | 2020-10-13 15:26:58 +0800 | [diff] [blame] | 41 | deps |
| 42 | ]), |
| 43 | workdir: meson.current_source_dir()) |
Patrick Williams | 953315d | 2022-03-16 14:30:39 -0500 | [diff] [blame] | 44 | endforeach |