Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistent testing #31

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 18 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,40 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
${Boost_LIBRARIES})

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

target_include_directories(codec_${name}_test PRIVATE
set(additional_args "")
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})

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

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

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

${Boost_INCLUDE_DIRS})

if(NOT CMAKE_CXX_STANDARD)
set_target_properties(codec_${name}_test PROPERTIES
set_target_properties(${test_name} PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED TRUE)
endif()

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

endif()

target_compile_definitions(${test_name} PRIVATE TEST_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data/")
endmacro()

set(TESTS_NAMES "hex" "base")
Expand Down
2 changes: 1 addition & 1 deletion test/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace boost {
} // namespace test_tools
} // namespace boost

const char *test_data = "data/base.json";
std::string test_data = std::string(TEST_DATA_DIR) + R"(base.json)";

boost::property_tree::ptree base_data(const char *child_name) {
boost::property_tree::ptree root_data;
Expand Down
2 changes: 1 addition & 1 deletion test/hex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace boost {
} // namespace test_tools
}

const char *test_data = "data/hex.json";
std::string test_data = std::string(TEST_DATA_DIR) + R"(hex.json)";

boost::property_tree::ptree mode_data(const char *mode) {
boost::property_tree::ptree root_data;
Expand Down