|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | + |
| 3 | +project(TestCustomPaths) |
| 4 | + |
| 5 | +find_package(Pytest REQUIRED) |
| 6 | + |
| 7 | +enable_testing() |
| 8 | + |
| 9 | +pytest_discover_tests( |
| 10 | + TestCustomPaths.FromConfig |
| 11 | +) |
| 12 | +set(EXPECTED |
| 13 | + "TestCustomPaths.FromConfig.test_addition" |
| 14 | + "TestCustomPaths.FromConfig.test_concat" |
| 15 | + "TestCustomPaths.FromConfig.test_power" |
| 16 | + "TestCustomPaths.FromConfig.test_substraction" |
| 17 | + "TestCustomPaths.FromConfig.test_upper" |
| 18 | +) |
| 19 | +add_test(NAME TestCustomPaths.Validate.FromConfig |
| 20 | + COMMAND ${CMAKE_COMMAND} |
| 21 | + -D "TEST_PREFIX=TestCustomPaths.FromConfig" |
| 22 | + -D "EXPECTED=${EXPECTED}" |
| 23 | + -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake |
| 24 | +) |
| 25 | + |
| 26 | +pytest_discover_tests( |
| 27 | + TestCustomPaths.BundledFromConfig |
| 28 | + BUNDLE_TESTS |
| 29 | +) |
| 30 | +set(EXPECTED |
| 31 | + "TestCustomPaths.BundledFromConfig" |
| 32 | +) |
| 33 | +add_test(NAME TestCustomPaths.Validate.BundledFromConfig |
| 34 | + COMMAND ${CMAKE_COMMAND} |
| 35 | + -D "TEST_PREFIX=TestCustomPaths.BundledFromConfig" |
| 36 | + -D "EXPECTED=${EXPECTED}" |
| 37 | + -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake |
| 38 | +) |
| 39 | + |
| 40 | +pytest_discover_tests( |
| 41 | + TestCustomPaths.FilePaths |
| 42 | + TEST_PATHS |
| 43 | + ${CMAKE_CURRENT_LIST_DIR}/test_a/math/test_add.py |
| 44 | + test_a/choice.py |
| 45 | + test_b/test_concat.py |
| 46 | +) |
| 47 | +set(EXPECTED |
| 48 | + "TestCustomPaths.FilePaths.test_addition" |
| 49 | + "TestCustomPaths.FilePaths.test_concat" |
| 50 | + "TestCustomPaths.FilePaths.test_random" |
| 51 | +) |
| 52 | +add_test(NAME TestCustomPaths.Validate.FilePaths |
| 53 | + COMMAND ${CMAKE_COMMAND} |
| 54 | + -D "TEST_PREFIX=TestCustomPaths.FilePaths" |
| 55 | + -D "EXPECTED=${EXPECTED}" |
| 56 | + -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake |
| 57 | +) |
| 58 | + |
| 59 | +pytest_discover_tests( |
| 60 | + TestCustomPaths.DirPaths |
| 61 | + TEST_PATHS |
| 62 | + test_a |
| 63 | + ${CMAKE_CURRENT_LIST_DIR}/test_b/math |
| 64 | +) |
| 65 | +set(EXPECTED |
| 66 | + "TestCustomPaths.DirPaths.test_addition" |
| 67 | + "TestCustomPaths.DirPaths.test_power" |
| 68 | + "TestCustomPaths.DirPaths.test_substraction" |
| 69 | + "TestCustomPaths.DirPaths.test_upper" |
| 70 | +) |
| 71 | +add_test(NAME TestCustomPaths.Validate.DirPaths |
| 72 | + COMMAND ${CMAKE_COMMAND} |
| 73 | + -D "TEST_PREFIX=TestCustomPaths.DirPaths" |
| 74 | + -D "EXPECTED=${EXPECTED}" |
| 75 | + -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake |
| 76 | +) |
| 77 | + |
| 78 | +pytest_discover_tests( |
| 79 | + TestCustomPaths.WithWorkingDirectory |
| 80 | + TEST_PATHS |
| 81 | + math |
| 82 | + choice.py |
| 83 | + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test_a |
| 84 | +) |
| 85 | +set(EXPECTED |
| 86 | + "TestCustomPaths.WithWorkingDirectory.test_addition" |
| 87 | + "TestCustomPaths.WithWorkingDirectory.test_random" |
| 88 | +) |
| 89 | +add_test(NAME TestCustomPaths.Validate.WithWorkingDirectory |
| 90 | + COMMAND ${CMAKE_COMMAND} |
| 91 | + -D "TEST_PREFIX=TestCustomPaths.WithWorkingDirectory" |
| 92 | + -D "EXPECTED=${EXPECTED}" |
| 93 | + -P ${CMAKE_CURRENT_LIST_DIR}/../utils/compare_discovered_tests.cmake |
| 94 | +) |
0 commit comments