Skip to content

Commit

Permalink
feat: add unit tests in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
maxday committed Aug 14, 2024
1 parent 934d254 commit 5796aad
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 27,156 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Checks:
-modernize-use-trailing-return-type,-bugprone-easily-swappable-parameters,-readability-identifier-length'
WarningsAsErrors: '*'
HeaderFilterRegex: 'include/aws/.*\.h$'
ExcludeHeaderFilter: 'build/_deps/gtest-src.*'
FormatStyle: 'none'
CheckOptions:
- key: modernize-pass-by-value.ValuesOnly
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test It
run: cd build && make && ctest

build-on-arm-too:
runs-on: ubuntu-latest
steps:
Expand All @@ -45,6 +48,7 @@ jobs:
apt-get update && apt-get install -y cmake g++ clang-tidy libcurl4-openssl-dev
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_CLANG_TIDY=clang-tidy
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
cd build && make && ctest
build-demo:
runs-on: ubuntu-latest
Expand Down
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ else ()
target_compile_definitions(${PROJECT_NAME} PRIVATE "AWS_LAMBDA_LOG=0")
endif()

#tests
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

enable_testing()
add_subdirectory(tests)


#versioning
configure_file(
Expand Down
36 changes: 25 additions & 11 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
project(aws-lambda-runtime-tests LANGUAGES CXX)

find_package(AWSSDK COMPONENTS lambda iam)
include(FetchContent)
FetchContent_Declare(gtest
QUIET
URL https://github.com/google/googletest/archive/v1.15.2.tar.gz
)
# configure build of googletest
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF)
FetchContent_MakeAvailable(gtest)

add_executable(${PROJECT_NAME}
main.cpp
runtime_tests.cpp
version_tests.cpp
gtest/gtest-all.cc)
add_executable(
unit_tests
no_op_test.cpp
)

target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LINK_LIBRARIES} aws-lambda-runtime)
target_link_libraries(unit_tests
PRIVATE
gtest_main
)

# automatic discovery of unit tests
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME} EXTRA_ARGS "--aws_prefix=${TEST_RESOURCE_PREFIX}") # requires CMake 3.10 or later

add_subdirectory(resources)

gtest_discover_tests(unit_tests
PROPERTIES
LABELS "unit"
DISCOVERY_TIMEOUT # how long to wait (in seconds) before crashing
240
)
3 changes: 0 additions & 3 deletions tests/gtest/.clang-tidy

This file was deleted.

Loading

0 comments on commit 5796aad

Please sign in to comment.