Skip to content

Commit

Permalink
Migrate some tests to CTest
Browse files Browse the repository at this point in the history
  • Loading branch information
thejohnfreeman committed Dec 6, 2024
1 parent ea1fffe commit dcbb3c6
Show file tree
Hide file tree
Showing 34 changed files with 940 additions and 946 deletions.
30 changes: 21 additions & 9 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,28 @@ DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^<(test)/'
Priority: 0
- Regex: '^<(xrpld)/'
Priority: 1
- Regex: '^<(xrpl)/'
Priority: 2
- Regex: '^<(boost)/'
Priority: 3
# Do not place anything at priority 0. That is the priority for the "main"
# header, the header corresponding to an implementation file.
# Private headers of our CTest tests.
- Regex: '^<tests/'
Priority: 10
# Private headers of our non-CTest tests.
- Regex: '^<test/'
Priority: 20
# Private headers of our internal targets.
- Regex: '^<(libxrpl|xrpld)/'
Priority: 30
# Public headers of our internal libraries.
- Regex: '^<xrpl/'
Priority: 40
# External libraries.
- Regex: '^<.*/'
Priority: 50
- Regex: '\.h(pp)?>$'
Priority: 50
# Standard library.
- Regex: '.*'
Priority: 4
Priority: 100
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: false
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ set_target_properties(OpenSSL::SSL PROPERTIES
INTERFACE_COMPILE_DEFINITIONS OPENSSL_NO_SSL2
)
set(SECP256K1_INSTALL TRUE)
set(SECP256K1_BUILD_BENCHMARK FALSE)
set(SECP256K1_BUILD_TESTS FALSE)
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS FALSE)
set(SECP256K1_BUILD_CTIME_TESTS FALSE)
set(SECP256K1_BUILD_EXAMPLES FALSE)
add_subdirectory(external/secp256k1)
add_library(secp256k1::secp256k1 ALIAS secp256k1)
add_subdirectory(external/ed25519-donna)
Expand Down Expand Up @@ -124,3 +129,8 @@ set(PROJECT_EXPORT_SET RippleExports)
include(RippledCore)
include(RippledInstall)
include(RippledValidatorKeys)

if(tests)
include(CTest)
add_subdirectory(tests)
endif()
37 changes: 37 additions & 0 deletions cmake/xrpl_add_test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
include(isolate_headers)

function(xrpl_add_test name)
set(target ${PROJECT_NAME}.test.${name})
add_executable(${target} EXCLUDE_FROM_ALL ${ARGN})

file(GLOB_RECURSE sources CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/${name}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.cpp"
)
target_sources(${target} PRIVATE ${sources})

isolate_headers(
${target}
"${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/tests/${name}"
PRIVATE
)

add_test(NAME ${target} COMMAND ${target})
set_tests_properties(
${target} PROPERTIES
FIXTURES_REQUIRED ${target}_fixture
)

add_test(
NAME ${target}.build
COMMAND
${CMAKE_COMMAND}
--build ${CMAKE_BINARY_DIR}
--config $<CONFIG>
--target ${target}
)
set_tests_properties(${target}.build PROPERTIES
FIXTURES_SETUP ${target}_fixture
)
endfunction()
2 changes: 2 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Xrpl(ConanFile):

requires = [
'date/3.0.1',
'doctest/2.4.11',
'grpc/1.50.1',
'libarchive/3.6.2',
'nudb/2.0.8',
Expand Down Expand Up @@ -116,6 +117,7 @@ def requirements(self):
'external/*',
'include/*',
'src/*',
'tests/*',
)

def layout(self):
Expand Down
2 changes: 1 addition & 1 deletion include/xrpl/basics/CompressionAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#define RIPPLED_COMPRESSIONALGORITHMS_H_INCLUDED

#include <xrpl/basics/contract.h>
#include <lz4.h>
#include <algorithm>
#include <cstdint>
#include <lz4.h>
#include <stdexcept>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/crypto/csprng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <xrpl/basics/contract.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/crypto/csprng.h>
#include <array>
#include <openssl/rand.h>
#include <array>
#include <random>
#include <stdexcept>

Expand Down
2 changes: 1 addition & 1 deletion src/libxrpl/protocol/SecretKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <xrpl/protocol/SecretKey.h>
#include <xrpl/protocol/detail/secp256k1.h>
#include <xrpl/protocol/digest.h>
#include <cstring>
#include <ed25519.h>
#include <cstring>

namespace ripple {

Expand Down
2 changes: 1 addition & 1 deletion src/test/app/ValidatorSite_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <chrono>
#include <date/date.h>
#include <chrono>

namespace ripple {
namespace test {
Expand Down
144 changes: 0 additions & 144 deletions src/test/basics/RangeSet_test.cpp

This file was deleted.

Loading

0 comments on commit dcbb3c6

Please sign in to comment.