Skip to content

Commit

Permalink
tests: upgrade Catch2 to version 3.6.0 (#2049)
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat authored Jun 17, 2024
1 parent 8b45d35 commit 48b6800
Show file tree
Hide file tree
Showing 250 changed files with 510 additions and 433 deletions.
4 changes: 2 additions & 2 deletions cmake/common/targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function(silkworm_library TARGET)
# unit tests
if(TEST_SRC AND NOT ${ARG_NO_TEST})
set(TEST_TARGET ${TARGET}_test)
add_executable(${TEST_TARGET} "${SILKWORM_MAIN_DIR}/cmd/test/unit_test.cpp" ${TEST_SRC})
target_link_libraries(${TEST_TARGET} PRIVATE Catch2::Catch2 ${TARGET})
add_executable(${TEST_TARGET} ${TEST_SRC})
target_link_libraries(${TEST_TARGET} PRIVATE Catch2::Catch2WithMain ${TARGET})
endif()
endfunction()
9 changes: 9 additions & 0 deletions cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ if(SILKWORM_SANITIZE_COMPILER_OPTIONS)
# cmake-format: on
endif()

if(SILKWORM_USE_MIMALLOC)
# mimalloc should not be used in sanitizer builds or at least its override option must be disabled
# (https://github.com/microsoft/mimalloc/issues/317#issuecomment-708506405) override option causes a crash on macOS at
# startup in rpcdaemon, so we enable it just on Linux
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND NOT SILKWORM_SANITIZE)
list(APPEND CONAN_OPTIONS "mimalloc:override=True")
endif()
endif()

conan_cmake_install(
PATH_OR_REFERENCE "${CONAN_BINARY_DIR}"
INSTALL_FOLDER "${CONAN_BINARY_DIR}"
Expand Down
12 changes: 9 additions & 3 deletions cmd/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@ find_package(magic_enum REQUIRED)

# Silkworm Core Tests
file(GLOB_RECURSE SILKWORM_CORE_TESTS CONFIGURE_DEPENDS "${SILKWORM_MAIN_SRC_DIR}/core/*_test.cpp")
add_executable(core_test unit_test.cpp ${SILKWORM_CORE_TESTS})

target_link_libraries(core_test silkworm_core Catch2::Catch2)
if(SILKWORM_WASM_API)
# Stub clang exception handlers on WASM after Catch2 3.x due to https://github.com/WebAssembly/wasi-sdk/issues/329
add_executable(core_test "${SILKWORM_MAIN_SRC_DIR}/wasm/exception_handling_stub.cpp" ${SILKWORM_CORE_TESTS})
# Skip generation of RPATH linker option for wasm-ld present by default after building Catch2 v3.6.0 from sources
set_target_properties(core_test PROPERTIES SKIP_BUILD_RPATH TRUE)
else()
add_executable(core_test ${SILKWORM_CORE_TESTS})
endif()
target_link_libraries(core_test silkworm_core Catch2::Catch2WithMain)

if(MSVC)
target_compile_options(core_test PRIVATE /EHa- /EHsc)
Expand Down
8 changes: 4 additions & 4 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SilkwormRecipe(ConanFile):
generators = 'cmake_find_package'

def requirements(self):
self.requires('catch2/2.13.9')
self.requires('catch2/3.6.0')
self.requires('magic_enum/0.8.2')
self.requires('ms-gsl/4.0.0')
self.requires('nlohmann_json/3.11.3')
Expand Down Expand Up @@ -58,9 +58,9 @@ def configure(self):
if self.settings.os == 'Windows':
return

# mimalloc override=True causes a crash on macOS at startup in rpcdaemon, so we just enable it on Linux
if self.settings.os == 'Linux':
self.options['mimalloc'].override = True
# Disable Catch2 version 3.x.x signaling handling on WASM
if self.settings.arch == 'wasm':
self.options['catch2'].no_posix_signals = True

self.options['boost'].asio_no_deprecated = True
if self.settings.os == 'Macos':
Expand Down
2 changes: 1 addition & 1 deletion silkworm/capi/silkworm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <cstring>
#include <iostream>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/trie/vector_root.hpp>
#include <silkworm/db/bodies/body_index.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/chain/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <vector>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/test_util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/chain/genesis_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <nlohmann/json.hpp>

#include <silkworm/core/chain/config.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/block_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "block_cache.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/bytes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "bytes.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/empty_hashes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <bit>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/rlp/encode.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/endian_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <bit>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/lru_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "lru_cache.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/math_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "math.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm::math {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/random_number_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <algorithm>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/small_map_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "small_map.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/common/util_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "util.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/types/evmc_bytes32.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/crypto/sha256_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>
#include <silkworm/core/crypto/sha256.h>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/execution/evm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <map>
#include <vector>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <evmone/execution_state.hpp>

#include <silkworm/core/common/test_util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/execution/execution_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "execution.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <ethash/keccak.hpp>

#include <silkworm/core/common/test_util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/execution/precompile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "precompile.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/execution/processor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "processor.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <evmc/evmc.hpp>

#include <silkworm/core/protocol/param.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/bor/config_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <string_view>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

using namespace std::string_view_literals;

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/bor/span_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "span.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/common/util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/clique_rule_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "clique_rule_set.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/state/in_memory_state.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/ethash_rule_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "ethash_rule_set.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm::protocol {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/intrinsic_gas_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "intrinsic_gas.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include "param.hpp"

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/merge_rule_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "merge_rule_set.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/empty_hashes.hpp>
#include <silkworm/core/state/in_memory_state.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/rule_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "rule_set.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/test_util.hpp>
#include <silkworm/core/protocol/param.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/protocol/validation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "validation.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/empty_hashes.hpp>
#include <silkworm/core/common/test_util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/rlp/decode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "decode.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/rlp/encode_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>
#include <silkworm/core/rlp/encode_vector.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/state/intra_block_state_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <utility>
#include <vector>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/random_number.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/trie/hash_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <iterator>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <ethash/keccak.hpp>

#include <silkworm/core/common/empty_hashes.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/trie/nibbles_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <vector>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>
#include <silkworm/core/trie/nibbles.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/trie/node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <bit>
#include <utility>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/trie/prefix_set_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "prefix_set.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/common/util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/trie/vector_root_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "vector_root.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/empty_hashes.hpp>
#include <silkworm/core/common/util.hpp>
Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/types/account_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "account.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/util.hpp>

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/types/address_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "address.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/types/block_body_for_storage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "block_body_for_storage.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

namespace silkworm {

Expand Down
2 changes: 1 addition & 1 deletion silkworm/core/types/block_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "block.hpp"

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>

#include <silkworm/core/common/bytes_to_string.hpp>
#include <silkworm/core/common/empty_hashes.hpp>
Expand Down
Loading

0 comments on commit 48b6800

Please sign in to comment.