Skip to content

Commit

Permalink
cmake,ci: Export JSON tests (#948)
Browse files Browse the repository at this point in the history
Rework CMake tests definition for exporting JSON tests
and store the exported fixtures as a CI artifact.
  • Loading branch information
chfast authored Jul 12, 2024
1 parent 8e2e110 commit 70ca837
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 52 deletions.
4 changes: 4 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ jobs:
steps:
- build
- test
- run:
name: "Export JSON tests"
working_directory: ~/package
command: tar -C ~/build/test/integration/export -cz fixtures > evmone-tests.tar.gz
- package

release-windows:
Expand Down
1 change: 1 addition & 0 deletions test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ DUP1,4
endif()

add_subdirectory(eofparse)
add_subdirectory(export)
add_subdirectory(statetest)
add_subdirectory(t8n)

Expand Down
59 changes: 59 additions & 0 deletions test/integration/export/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# evmone: Fast Ethereum Virtual Machine implementation
# Copyright 2023 The evmone Authors.
# SPDX-License-Identifier: Apache-2.0

# Commands and tests for exporting evmone's tests to JSON formats

set(PREFIX ${PREFIX}/export)
set(EXPORT_DIR fixtures)

add_test(
# Clean the export directory before exporting to delete potentially outdated tests.
NAME ${PREFIX}/clean_export_dir
COMMAND ${CMAKE_COMMAND} -E rm -rf ${EXPORT_DIR}
)
set_tests_properties(
${PREFIX}/clean_export_dir PROPERTIES
FIXTURES_SETUP EXPORT_PREPARATION
)

add_test(
NAME ${PREFIX}/export_state_tests
COMMAND evmone-unittests --gtest_filter=state_transition.*
)
set_tests_properties(
${PREFIX}/export_state_tests PROPERTIES
ENVIRONMENT EVMONE_EXPORT_TESTS=${EXPORT_DIR}/state_tests
FIXTURES_SETUP EXPORT_STATE_TESTS
FIXTURES_REQUIRED EXPORT_PREPARATION
)

add_test(
NAME ${PREFIX}/execute_exported_state_tests
# TODO: Broken exported tests are filtered out.
COMMAND evmone-statetest ${EXPORT_DIR}/state_tests --gtest_filter=-*block.*
)
set_tests_properties(
${PREFIX}/execute_exported_state_tests PROPERTIES
FIXTURES_REQUIRED EXPORT_STATE_TESTS
)

add_test(
NAME ${PREFIX}/export_eof_tests
COMMAND evmone-unittests --gtest_filter=eof_validation.*
)
set_tests_properties(
${PREFIX}/export_eof_tests PROPERTIES
ENVIRONMENT EVMONE_EXPORT_TESTS=${EXPORT_DIR}/eof_tests
FIXTURES_SETUP EXPORT_EOF_TESTS
FIXTURES_REQUIRED EXPORT_PREPARATION
)

add_test(
NAME ${PREFIX}/execute_exported_eof_tests
COMMAND evmone-eoftest ${EXPORT_DIR}/eof_tests
)
set_tests_properties(
${PREFIX}/execute_exported_eof_tests PROPERTIES
FIXTURES_REQUIRED EXPORT_EOF_TESTS
)
52 changes: 0 additions & 52 deletions test/integration/statetest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,55 +126,3 @@ set_tests_properties(
${PREFIX}/tx_invalid_nonce PROPERTIES
PASS_REGULAR_EXPRESSION "unexpected invalid transaction: nonce too high"
)

# Tests for exporting JSON tests

set(EXPORT_DIR exported_tests)

add_test(
NAME ${PREFIX}/export_to_json
COMMAND evmone-unittests --gtest_filter=state_transition.*
)
set_tests_properties(
${PREFIX}/export_to_json PROPERTIES
ENVIRONMENT EVMONE_EXPORT_TESTS=${EXPORT_DIR}
FIXTURES_SETUP EXPORT_JSON_TESTS
)

add_test(
NAME ${PREFIX}/export_to_json_created_files
COMMAND ${CMAKE_COMMAND} -E sha256sum ${EXPORT_DIR}/state_transition/block/known_block_hash.json
)
set_tests_properties(
${PREFIX}/export_to_json_created_files PROPERTIES
FIXTURES_REQUIRED EXPORT_JSON_TESTS
)

add_test(
NAME ${PREFIX}/execute_exported_tests
# TODO: Broken exported tests are filtered out.
COMMAND evmone-statetest ${EXPORT_DIR}/state_transition --gtest_filter=-*block.*
)
set_tests_properties(
${PREFIX}/execute_exported_tests PROPERTIES
FIXTURES_REQUIRED EXPORT_JSON_TESTS
)

add_test(
NAME ${PREFIX}/export_validation_tests_to_json
COMMAND evmone-unittests --gtest_filter=eof_validation.*
)
set_tests_properties(
${PREFIX}/export_validation_tests_to_json PROPERTIES
ENVIRONMENT EVMONE_EXPORT_TESTS=${EXPORT_DIR}
FIXTURES_SETUP EXPORT_JSON_VALIDATION_TESTS
)

add_test(
NAME ${PREFIX}/execute_exported_validation_tests
COMMAND evmone-eoftest ${EXPORT_DIR}/eof_validation
)
set_tests_properties(
${PREFIX}/execute_exported_validation_tests PROPERTIES
FIXTURES_REQUIRED EXPORT_JSON_VALIDATION_TESTS
)

0 comments on commit 70ca837

Please sign in to comment.