John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 1 | gtest = dependency('gtest', main: true, disabler: true, required: false) |
| 2 | gmock = dependency('gmock', disabler: true, required: false) |
| 3 | if not gtest.found() or not gmock.found() |
| 4 | gtest_proj = import('cmake').subproject('googletest', required: false) |
| 5 | if gtest_proj.found() |
| 6 | gtest = declare_dependency( |
| 7 | dependencies: [ |
| 8 | dependency('threads'), |
| 9 | gtest_proj.dependency('gtest'), |
| 10 | gtest_proj.dependency('gtest_main'), |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 11 | ], |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 12 | ) |
| 13 | gmock = gtest_proj.dependency('gmock') |
| 14 | else |
| 15 | assert( |
| 16 | not get_option('tests').allowed(), |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 17 | 'Googletest is required if tests are enabled', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 18 | ) |
| 19 | endif |
| 20 | endif |
| 21 | |
| 22 | sources = [ |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 23 | 'ir-tests.cpp', |
| 24 | 'test-utils.cpp', |
Ed Tanous | a7d2cdd | 2024-07-15 11:07:27 -0700 | [diff] [blame^] | 25 | 'base64_test.cpp', |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 26 | ] |
| 27 | |
| 28 | test_include_dirs = ['.', '..'] |
| 29 | |
| 30 | run_command('cp', '-r', '../specification/json/', meson.current_build_dir()) |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 31 | run_command( |
| 32 | 'mv', |
| 33 | meson.current_build_dir() / 'json', |
| 34 | meson.current_build_dir() / 'specification', |
| 35 | ) |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 36 | |
| 37 | tests = ['cper-tests'] |
| 38 | |
Ed Tanous | c833a3a | 2024-07-15 11:53:53 -0700 | [diff] [blame] | 39 | test( |
| 40 | 'test-cper-tests', |
| 41 | executable( |
| 42 | 'cper-tests', |
| 43 | sources, |
| 44 | implicit_include_directories: false, |
| 45 | include_directories: include_directories(test_include_dirs), |
| 46 | cpp_args: '-fpermissive', |
| 47 | dependencies: [libcper_parse, libcper_generate, json_c_dep, gtest, gmock], |
| 48 | ), |
John Chung | 197ea12 | 2024-05-03 19:57:55 +0800 | [diff] [blame] | 49 | ) |