Skip to content

Commit

Permalink
Add consistent testing
Browse files Browse the repository at this point in the history
  • Loading branch information
x-mass committed Nov 29, 2023
1 parent a6662a4 commit 8633a39
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 6 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/publish-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Needed to publish test results in fork
name: Testing Callback

on:
workflow_run:
workflows: ["PR Testing"]
types:
- completed

jobs:
call-reusable-workflow:
name: Call Reusable Testing Callback Workflow
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-publish-result.yml@v1
24 changes: 24 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: PR Testing

on:
pull_request:
types:
- opened
- synchronize

jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1
with:
ci-cd-ref: 'v1'
secrets: inherit

matrix-test:
name: Call Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing.yml@v1
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
secrets: inherit
27 changes: 21 additions & 6 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,42 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}


macro(define_runtime_algebra_test name)
cm_test(NAME algebra_${name}_test SOURCES ${name}.cpp)
set(test_name "algebra_${name}_test")

set(additional_args "")
message(STATUS "here")
if(ENABLE_JUNIT_TEST_OUTPUT)
set(TEST_RESULTS_DIR "${CMAKE_CURRENT_BINARY_DIR}/junit_results")
set(TEST_LOGS_DIR "${TEST_RESULTS_DIR}/logs")
file(MAKE_DIRECTORY ${TEST_LOGS_DIR} ${TEST_REPORTS_DIR})

set(additional_args "--log_format=JUNIT"
"--log_sink=${TEST_LOGS_DIR}/${test_name}.xml")
message(STATUS "additional_args: ${additional_args}")
endif()

cm_test(NAME ${test_name} SOURCES ${name}.cpp ARGS ${additional_args})

target_include_directories(algebra_${name}_test PRIVATE
target_include_directories(${test_name} PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

set_target_properties(algebra_${name}_test PROPERTIES CXX_STANDARD 17
set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE)

get_target_property(target_type Boost::unit_test_framework TYPE)
if(target_type STREQUAL "SHARED_LIB")
target_compile_definitions(algebra_${name}_test PRIVATE BOOST_TEST_DYN_LINK)
target_compile_definitions(${test_name} PRIVATE BOOST_TEST_DYN_LINK)
elseif(target_type STREQUAL "STATIC_LIB")

endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(algebra_${name}_test PRIVATE "-fconstexpr-steps=2147483647")
target_compile_options(${test_name} PRIVATE "-fconstexpr-steps=2147483647")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(algebra_${name}_test PRIVATE "-fconstexpr-ops-limit=4294967295")
target_compile_options(${test_name} PRIVATE "-fconstexpr-ops-limit=4294967295")
endif()
endmacro()

Expand Down Expand Up @@ -81,6 +95,7 @@ set(COMPILE_TIME_TESTS_NAMES
"vector")

foreach(TEST_NAME ${RUNTIME_TESTS_NAMES})
message(STATUS "for each")
define_runtime_algebra_test(${TEST_NAME})
endforeach()

Expand Down

0 comments on commit 8633a39

Please sign in to comment.