1
1
cmake_minimum_required (VERSION 3.11 )
2
2
project (aws-lambda-runtime-tests LANGUAGES CXX )
3
3
4
- # Fetch Google Test
5
- # We're using the latest supported version which supports C++11 (https://github.com/google/googletest/releases/tag/release-1.12.0)
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
- # Common test library setup
18
- add_library (test_common INTERFACE )
19
- target_link_libraries (test_common INTERFACE gtest_main )
20
-
21
- # Unit tests executable
22
- add_executable (unit_tests
23
- unit/no_op_test.cpp )
24
- target_link_libraries (unit_tests PRIVATE test_common aws-lambda-runtime )
4
+ # Only fetch and setup Google Test in GitHub Actions
5
+ if (DEFINED ENV{GITHUB_RUN_ID} )
6
+ # Fetch Google Test for GitHub Actions
7
+ include (FetchContent )
8
+ FetchContent_Declare (gtest
9
+ URL https://github.com/google/googletest/archive/v1.12.0.tar.gz
10
+ DOWNLOAD_EXTRACT_TIMESTAMP TRUE
11
+ )
12
+ # Configure build of googletest
13
+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
14
+ set (BUILD_GMOCK OFF CACHE BOOL "" FORCE )
15
+ set (INSTALL_GTEST OFF )
16
+ FetchContent_MakeAvailable (gtest )
17
+
18
+ # Common test library setup
19
+ add_library (test_common INTERFACE )
20
+ target_link_libraries (test_common INTERFACE GTest::GTest GTest::Main )
21
+
22
+ # Unit tests executable
23
+ add_executable (unit_tests
24
+ unit/no_op_test.cpp )
25
+ target_link_libraries (unit_tests PRIVATE test_common aws-lambda-runtime )
26
+
27
+ # Register unit tests with CTest
28
+ include (GoogleTest )
29
+ gtest_discover_tests (unit_tests
30
+ PROPERTIES
31
+ LABELS "unit"
32
+ DISCOVERY_TIMEOUT 10 )
33
+ endif ()
25
34
26
35
# Integration tests executable (only if enabled)
27
36
if (ENABLE_INTEGRATION_TESTS )
@@ -32,26 +41,16 @@ if (ENABLE_INTEGRATION_TESTS)
32
41
integration/version_tests.cpp )
33
42
target_link_libraries (integration_tests
34
43
PRIVATE
35
- test_common
36
44
aws-lambda-runtime
37
45
${AWSSDK_LINK_LIBRARIES} )
38
- endif ()
39
-
40
- # Register tests with CTest
41
- include (GoogleTest )
42
- gtest_discover_tests (unit_tests
43
- PROPERTIES
44
- LABELS "unit"
45
- DISCOVERY_TIMEOUT 10 )
46
46
47
- if (ENABLE_INTEGRATION_TESTS )
47
+ # Register integration tests with CTest
48
+ include (GoogleTest )
48
49
gtest_discover_tests (integration_tests
49
50
PROPERTIES
50
51
LABELS "integration"
51
52
EXTRA_ARGS "--aws_prefix=${TEST_RESOURCE_PREFIX} " )
52
- endif ()
53
53
54
- if (ENABLE_INTEGRATION_TESTS )
55
54
add_subdirectory (resources )
56
55
endif ()
57
56
0 commit comments