|
1 | 1 | cmake_minimum_required(VERSION 3.11)
|
2 | 2 | project(aws-lambda-runtime-tests LANGUAGES CXX)
|
3 | 3 |
|
4 |
| -# Fetch Google Test for unit tests |
5 |
| -include(FetchContent) |
6 |
| -FetchContent_Declare(gtest |
7 |
| - URL https://github.com/google/googletest/archive/v1.12.0.tar.gz |
8 |
| - DOWNLOAD_EXTRACT_TIMESTAMP TRUE |
9 |
| -) |
10 |
| -# Configure build of googletest |
11 |
| -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
12 |
| -set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) |
13 |
| -set(INSTALL_GTEST OFF) |
14 |
| -FetchContent_MakeAvailable(gtest) |
15 |
| - |
16 |
| -# Unit tests executable |
17 |
| -add_executable(unit_tests |
18 |
| - unit/no_op_test.cpp) |
19 |
| -target_link_libraries(unit_tests PRIVATE gtest_main aws-lambda-runtime) |
20 |
| - |
21 |
| -# Register unit tests with CTest |
22 |
| -include(GoogleTest) |
23 |
| -gtest_discover_tests(unit_tests |
24 |
| - PROPERTIES |
25 |
| - LABELS "unit" |
26 |
| - DISCOVERY_TIMEOUT 10) |
27 |
| - |
28 |
| -# Original integration tests setup |
29 |
| -find_package(AWSSDK COMPONENTS lambda iam) |
30 |
| - |
31 |
| -add_executable(${PROJECT_NAME} |
32 |
| - integration/main.cpp |
33 |
| - integration/runtime_tests.cpp |
34 |
| - integration/version_tests.cpp |
35 |
| - gtest/gtest-all.cc) |
36 |
| - |
37 |
| -target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} aws-lambda-runtime) |
38 |
| - |
39 |
| -include(GoogleTest) |
40 |
| -gtest_discover_tests(${PROJECT_NAME} EXTRA_ARGS "--aws_prefix=${TEST_RESOURCE_PREFIX}") # requires CMake 3.10 or later |
41 |
| - |
42 |
| -add_subdirectory(resources) |
| 4 | +if(DEFINED ENV{GITHUB_ACTIONS}) |
| 5 | + # Fetch Google Test for unit tests |
| 6 | + include(FetchContent) |
| 7 | + FetchContent_Declare(gtest |
| 8 | + URL https://github.com/google/googletest/archive/v1.12.0.tar.gz |
| 9 | + DOWNLOAD_EXTRACT_TIMESTAMP TRUE |
| 10 | + ) |
| 11 | + # Configure build of googletest |
| 12 | + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 13 | + set(BUILD_GMOCK OFF CACHE BOOL "" FORCE) |
| 14 | + set(INSTALL_GTEST OFF) |
| 15 | + FetchContent_MakeAvailable(gtest) |
| 16 | + |
| 17 | + # Unit tests executable |
| 18 | + add_executable(unit_tests |
| 19 | + unit/no_op_test.cpp) |
| 20 | + target_link_libraries(unit_tests PRIVATE gtest_main aws-lambda-runtime) |
| 21 | + |
| 22 | + # Register unit tests with CTest |
| 23 | + include(GoogleTest) |
| 24 | + gtest_discover_tests(unit_tests |
| 25 | + PROPERTIES |
| 26 | + LABELS "unit" |
| 27 | + DISCOVERY_TIMEOUT 10) |
| 28 | +else() |
| 29 | + message(STATUS "Unit tests skipped: Not in GitHub Actions environment") |
| 30 | +endif() |
| 31 | + |
| 32 | + |
| 33 | +find_package(AWSSDK COMPONENTS lambda iam QUIET) |
| 34 | + |
| 35 | +if(AWSSDK_FOUND) |
| 36 | + add_executable(${PROJECT_NAME} |
| 37 | + integration/main.cpp |
| 38 | + integration/runtime_tests.cpp |
| 39 | + integration/version_tests.cpp |
| 40 | + gtest/gtest-all.cc) |
| 41 | + |
| 42 | + target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} aws-lambda-runtime) |
| 43 | + |
| 44 | + include(GoogleTest) |
| 45 | + gtest_discover_tests(${PROJECT_NAME} EXTRA_ARGS "--aws_prefix=${TEST_RESOURCE_PREFIX}") # requires CMake 3.10 or later |
| 46 | + |
| 47 | + add_subdirectory(resources) |
| 48 | +else() |
| 49 | + message(STATUS "Integration tests skipped: AWS SDK not found or not in GitHub Actions environment") |
| 50 | +endif() |
43 | 51 |
|
0 commit comments