mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
make building tests optional:
* disable build specific commandline options when built without tests
This commit is contained in:
committed by
manojsdoshi
parent
90aa3c75a7
commit
da26d11593
19
.travis.yml
19
.travis.yml
@@ -123,6 +123,25 @@ matrix:
|
||||
- CMAKE_ADD="-Dcoverage=ON"
|
||||
- TARGET=coverage_report
|
||||
- SKIP_TESTS=true
|
||||
# test-free builds
|
||||
- <<: *linux
|
||||
if: commit_message !~ /travis_run_/ OR commit_message =~ /travis_run_linux/
|
||||
compiler: gcc-8
|
||||
name: no-tests-unity, gcc-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
- BUILD_TYPE=Debug
|
||||
- CMAKE_ADD="-Dtests=OFF"
|
||||
- SKIP_TESTS=true
|
||||
- <<: *linux
|
||||
if: commit_message !~ /travis_run_/ OR commit_message =~ /travis_run_linux/
|
||||
compiler: clang-8
|
||||
name: no-tests-non-unity, clang-8
|
||||
env:
|
||||
- MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
|
||||
- BUILD_TYPE=Debug
|
||||
- CMAKE_ADD="-Dtests=OFF -Dunity=OFF"
|
||||
- SKIP_TESTS=true
|
||||
# nounity
|
||||
- <<: *linux
|
||||
if: commit_message !~ /travis_run_/ OR commit_message =~ /travis_run_linux/ OR commit_message =~ /travis_run_nounity/
|
||||
|
||||
@@ -292,7 +292,8 @@ install (
|
||||
# WARNING!! -- horrible levelization ahead
|
||||
# (these files should be isolated or moved...but
|
||||
# unfortunately unit_test.h above creates this dependency)
|
||||
install (
|
||||
if (tests)
|
||||
install (
|
||||
FILES
|
||||
src/beast/extras/beast/unit_test/amount.hpp
|
||||
src/beast/extras/beast/unit_test/dstream.hpp
|
||||
@@ -307,11 +308,11 @@ install (
|
||||
src/beast/extras/beast/unit_test/suite_list.hpp
|
||||
src/beast/extras/beast/unit_test/thread.hpp
|
||||
DESTINATION include/beast/unit_test)
|
||||
install (
|
||||
install (
|
||||
FILES
|
||||
src/beast/extras/beast/unit_test/detail/const_container.hpp
|
||||
DESTINATION include/beast/unit_test/detail)
|
||||
|
||||
endif () #tests
|
||||
#[===================================================================[
|
||||
rippled executable
|
||||
#]===================================================================]
|
||||
@@ -325,6 +326,9 @@ add_executable (rippled src/ripple/app/main/Application.h)
|
||||
if (unity)
|
||||
set_target_properties(rippled PROPERTIES UNITY_BUILD ON)
|
||||
endif ()
|
||||
if (tests)
|
||||
target_compile_definitions(rippled PUBLIC ENABLE_TESTS)
|
||||
endif()
|
||||
target_sources (rippled PRIVATE
|
||||
#[===============================[
|
||||
main sources:
|
||||
@@ -655,11 +659,14 @@ target_sources (rippled PRIVATE
|
||||
src/ripple/shamap/impl/SHAMapNodeID.cpp
|
||||
src/ripple/shamap/impl/SHAMapSync.cpp
|
||||
src/ripple/shamap/impl/SHAMapTreeNode.cpp
|
||||
src/ripple/shamap/impl/ShardFamily.cpp
|
||||
src/ripple/shamap/impl/ShardFamily.cpp)
|
||||
|
||||
#[===============================[
|
||||
test sources:
|
||||
subdir: app
|
||||
#]===============================]
|
||||
if (tests)
|
||||
target_sources (rippled PRIVATE
|
||||
src/test/app/AccountDelete_test.cpp
|
||||
src/test/app/AccountTxPaging_test.cpp
|
||||
src/test/app/AmendmentTable_test.cpp
|
||||
@@ -966,6 +973,8 @@ target_sources (rippled PRIVATE
|
||||
subdir: unit_test
|
||||
#]===============================]
|
||||
src/test/unit_test/multi_runner.cpp)
|
||||
endif () #tests
|
||||
|
||||
target_link_libraries (rippled
|
||||
Ripple::boost
|
||||
Ripple::opts
|
||||
@@ -985,9 +994,11 @@ endif ()
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16)
|
||||
# any files that don't play well with unity should be added here
|
||||
if (tests)
|
||||
set_source_files_properties(
|
||||
# these two seem to produce conflicts in beast teardown template methods
|
||||
src/test/rpc/ValidatorRPC_test.cpp
|
||||
src/test/rpc/ShardArchiveHandler_test.cpp
|
||||
PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE)
|
||||
endif () #tests
|
||||
endif ()
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#[===================================================================[
|
||||
docs target (optional)
|
||||
#]===================================================================]
|
||||
|
||||
find_package (Doxygen)
|
||||
if (NOT TARGET Doxygen::doxygen)
|
||||
if (tests)
|
||||
find_package (Doxygen)
|
||||
if (NOT TARGET Doxygen::doxygen)
|
||||
message (STATUS "doxygen executable not found -- skipping docs target")
|
||||
return ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set (doxygen_output_directory "${CMAKE_BINARY_DIR}/docs")
|
||||
set (doxygen_include_path "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
set (doxygen_index_file "${doxygen_output_directory}/html/index.html")
|
||||
set (doxyfile "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile")
|
||||
set (doxygen_output_directory "${CMAKE_BINARY_DIR}/docs")
|
||||
set (doxygen_include_path "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
set (doxygen_index_file "${doxygen_output_directory}/html/index.html")
|
||||
set (doxyfile "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile")
|
||||
|
||||
file (GLOB_RECURSE doxygen_input
|
||||
file (GLOB_RECURSE doxygen_input
|
||||
docs/*.md
|
||||
src/ripple/*.h
|
||||
src/ripple/*.cpp
|
||||
@@ -21,13 +21,13 @@ file (GLOB_RECURSE doxygen_input
|
||||
src/test/*.h
|
||||
src/test/*.md
|
||||
Builds/*/README.md)
|
||||
list (APPEND doxygen_input
|
||||
list (APPEND doxygen_input
|
||||
README.md
|
||||
RELEASENOTES.md
|
||||
src/README.md)
|
||||
set (dependencies "${doxygen_input}" "${doxyfile}")
|
||||
set (dependencies "${doxygen_input}" "${doxyfile}")
|
||||
|
||||
function (verbose_find_path variable name)
|
||||
function (verbose_find_path variable name)
|
||||
# find_path sets a CACHE variable, so don't try using a "local" variable.
|
||||
find_path (${variable} "${name}" ${ARGN})
|
||||
if (NOT ${variable})
|
||||
@@ -35,15 +35,15 @@ function (verbose_find_path variable name)
|
||||
else ()
|
||||
message (STATUS "found ${name}: ${${variable}}/${name}")
|
||||
endif ()
|
||||
endfunction ()
|
||||
endfunction ()
|
||||
|
||||
verbose_find_path (doxygen_plantuml_jar_path plantuml.jar PATH_SUFFIXES share/plantuml)
|
||||
verbose_find_path (doxygen_dot_path dot)
|
||||
verbose_find_path (doxygen_plantuml_jar_path plantuml.jar PATH_SUFFIXES share/plantuml)
|
||||
verbose_find_path (doxygen_dot_path dot)
|
||||
|
||||
# https://en.cppreference.com/w/Cppreference:Archives
|
||||
# https://stackoverflow.com/questions/60822559/how-to-move-a-file-download-from-configure-step-to-build-step
|
||||
set (download_script "${CMAKE_BINARY_DIR}/docs/download-cppreference.cmake")
|
||||
file (WRITE
|
||||
# https://en.cppreference.com/w/Cppreference:Archives
|
||||
# https://stackoverflow.com/questions/60822559/how-to-move-a-file-download-from-configure-step-to-build-step
|
||||
set (download_script "${CMAKE_BINARY_DIR}/docs/download-cppreference.cmake")
|
||||
file (WRITE
|
||||
"${download_script}"
|
||||
"file (DOWNLOAD \
|
||||
http://upload.cppreference.com/mwiki/images/b/b2/html_book_20190607.zip \
|
||||
@@ -53,16 +53,16 @@ file (WRITE
|
||||
execute_process ( \
|
||||
COMMAND \"${CMAKE_COMMAND}\" -E tar -xf cppreference.zip \
|
||||
)\n"
|
||||
)
|
||||
set (tagfile "${CMAKE_BINARY_DIR}/docs/cppreference-doxygen-web.tag.xml")
|
||||
add_custom_command (
|
||||
)
|
||||
set (tagfile "${CMAKE_BINARY_DIR}/docs/cppreference-doxygen-web.tag.xml")
|
||||
add_custom_command (
|
||||
OUTPUT "${tagfile}"
|
||||
COMMAND "${CMAKE_COMMAND}" -P "${download_script}"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/docs"
|
||||
)
|
||||
set (doxygen_tagfiles "${tagfile}=http://en.cppreference.com/w/")
|
||||
)
|
||||
set (doxygen_tagfiles "${tagfile}=http://en.cppreference.com/w/")
|
||||
|
||||
add_custom_command (
|
||||
add_custom_command (
|
||||
OUTPUT "${doxygen_index_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E env
|
||||
"DOXYGEN_OUTPUT_DIRECTORY=${doxygen_output_directory}"
|
||||
@@ -73,6 +73,7 @@ add_custom_command (
|
||||
"${DOXYGEN_EXECUTABLE}" "${doxyfile}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
DEPENDS "${dependencies}" "${tagfile}")
|
||||
add_custom_target (docs
|
||||
add_custom_target (docs
|
||||
DEPENDS "${doxygen_index_file}"
|
||||
SOURCES "${dependencies}")
|
||||
endif ()
|
||||
|
||||
@@ -6,6 +6,8 @@ option (assert "Enables asserts, even in release builds" OFF)
|
||||
|
||||
option (reporting "Build rippled with reporting mode enabled" OFF)
|
||||
|
||||
option (tests "Build tests" ON)
|
||||
|
||||
option (unity "Creates a build using UNITY support in cmake. This is the default" ON)
|
||||
if (unity)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.16)
|
||||
|
||||
@@ -34,8 +34,10 @@
|
||||
#include <ripple/resource/Fees.h>
|
||||
#include <ripple/rpc/RPCHandler.h>
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
#include <beast/unit_test/match.hpp>
|
||||
#include <test/unit_test/multi_runner.h>
|
||||
#endif // ENABLE_TESTS
|
||||
|
||||
#include <google/protobuf/stubs/common.h>
|
||||
|
||||
@@ -184,6 +186,7 @@ printHelp(const po::options_description& desc)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
/* simple unit test selector that allows a comma separated list
|
||||
* of selectors
|
||||
*/
|
||||
@@ -335,6 +338,7 @@ runUnitTests(
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ENABLE_TESTS
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
int
|
||||
@@ -405,6 +409,7 @@ run(int argc, char** argv)
|
||||
"DEPRECATED: include with rpc_ip instead. "
|
||||
"Specify the port number for RPC command.");
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
po::options_description test("Unit Test Options");
|
||||
test.add_options()(
|
||||
"quiet,q",
|
||||
@@ -433,6 +438,7 @@ run(int argc, char** argv)
|
||||
"unittest-jobs",
|
||||
po::value<std::size_t>(),
|
||||
"Number of unittest jobs to run in parallel (child processes).");
|
||||
#endif // ENABLE_TESTS
|
||||
|
||||
// These are hidden options, not intended to be shown in the usage/help
|
||||
// message
|
||||
@@ -443,20 +449,37 @@ run(int argc, char** argv)
|
||||
"Specify rpc command and parameters. This option must be repeated "
|
||||
"for each command/param. Positional parameters also serve this "
|
||||
"purpose, "
|
||||
"so this option is not needed for users")(
|
||||
"unittest-child",
|
||||
"For internal use only when spawning child unit test processes.")(
|
||||
"fg", "Deprecated: server always in foreground mode.");
|
||||
"so this option is not needed for users")
|
||||
#ifdef ENABLE_TESTS
|
||||
("unittest-child",
|
||||
"For internal use only when spawning child unit test processes.")
|
||||
#else
|
||||
("unittest", "Disabled in this build.")(
|
||||
"unittest-child", "Disabled in this build.")
|
||||
#endif // ENABLE_TESTS
|
||||
("fg", "Deprecated: server always in foreground mode.");
|
||||
|
||||
// Interpret positional arguments as --parameters.
|
||||
po::positional_options_description p;
|
||||
p.add("parameters", -1);
|
||||
|
||||
po::options_description all;
|
||||
all.add(gen).add(rpc).add(data).add(test).add(hidden);
|
||||
all.add(gen)
|
||||
.add(rpc)
|
||||
.add(data)
|
||||
#ifdef ENABLE_TESTS
|
||||
.add(test)
|
||||
#endif // ENABLE_TESTS
|
||||
.add(hidden);
|
||||
|
||||
po::options_description desc;
|
||||
desc.add(gen).add(rpc).add(data).add(test);
|
||||
desc.add(gen)
|
||||
.add(rpc)
|
||||
.add(data)
|
||||
#ifdef ENABLE_TESTS
|
||||
.add(test)
|
||||
#endif // ENABLE_TESTS
|
||||
;
|
||||
|
||||
// Parse options, if no error.
|
||||
try
|
||||
@@ -489,6 +512,14 @@ run(int argc, char** argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef ENABLE_TESTS
|
||||
if (vm.count("unittest") || vm.count("unittest-child"))
|
||||
{
|
||||
std::cerr << "rippled: Tests disabled in this build." << std::endl;
|
||||
std::cerr << "Try 'rippled --help' for a list of options." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
// Run the unit tests if requested.
|
||||
// The unit tests will exit the application with an appropriate return code.
|
||||
//
|
||||
@@ -528,6 +559,7 @@ run(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_TESTS
|
||||
|
||||
auto config = std::make_unique<Config>();
|
||||
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace ripple {
|
||||
#ifdef ENABLE_TESTS
|
||||
namespace test {
|
||||
class ShardArchiveHandler_test;
|
||||
}
|
||||
#endif // ENABLE_TESTS
|
||||
namespace RPC {
|
||||
|
||||
/** Handles the download and import of one or more shard archives. */
|
||||
@@ -42,7 +44,9 @@ class ShardArchiveHandler
|
||||
public:
|
||||
using TimerOpCounter =
|
||||
ClosureCounter<void, boost::system::error_code const&>;
|
||||
#ifdef ENABLE_TESTS
|
||||
friend class test::ShardArchiveHandler_test;
|
||||
#endif // ENABLE_TESTS
|
||||
|
||||
static boost::filesystem::path
|
||||
getDownloadDirectory(Config const& config);
|
||||
|
||||
Reference in New Issue
Block a user