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

[nomerge] Update to latest vcpkg versions #714

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
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
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ if(NOT Boost_USE_STATIC_LIBS)
endif()

# Prevent cmake from finding system boost instead of toolchain boost.
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_NO_BOOST_CMAKE ON )
set(Boost_USE_MULTITHREADED ON )
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_NO_SYSTEM_PATHS ON )
find_package(
Boost
1.75
Expand All @@ -78,6 +79,15 @@ find_package(
find_package(yaml-cpp CONFIG REQUIRED)
# <yaml-cpp>

# <catch2>
find_package(Catch2 REQUIRED)
# </catch2>

# <mongo-cxx-driver>
find_package(mongocxx CONFIG REQUIRED)
find_package(bsoncxx CONFIG REQUIRED)
# <mongo-cxx-driver>

# Required CMAKE options
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF CACHE BOOL "")
Expand Down
44 changes: 0 additions & 44 deletions cmake/FindMongoCxx.cmake

This file was deleted.

58 changes: 31 additions & 27 deletions cmake/ParseAndAddCatchTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#
# Modifications to the base file have "GENNY CHANGE" comments.
#

#==================================================================================================#
# supported macros #
# - TEST_CASE, #
Expand Down Expand Up @@ -65,7 +64,7 @@
#==================================================================================================#

if (CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
message(FATAL_ERROR "ParseAndAddCatchTests requires CMake 2.8.8 or newer")
message(FATAL_ERROR "ParseAndAddCatchTests requires CMake 2.8.8 or newer")
endif()

option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
Expand All @@ -76,7 +75,7 @@ option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIG

function(ParseAndAddCatchTests_PrintDebugMessage)
if(PARSE_CATCH_TESTS_VERBOSE)
message(STATUS "ParseAndAddCatchTests: ${ARGV}")
message(STATUS "ParseAndAddCatchTests: ${ARGV}")
endif()
endfunction()

Expand All @@ -86,14 +85,14 @@ endfunction()
# contents have been read into '${CppCode}'.
# !keep partial line comments
function(ParseAndAddCatchTests_RemoveComments CppCode)
string(ASCII 2 CMakeBeginBlockComment)
string(ASCII 3 CMakeEndBlockComment)
string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}")
string(ASCII 2 CMakeBeginBlockComment)
string(ASCII 3 CMakeEndBlockComment)
string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}")
string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}")

set(${CppCode} "${${CppCode}}" PARENT_SCOPE)
set(${CppCode} "${${CppCode}}" PARENT_SCOPE)
endfunction()

# Worker function
Expand All @@ -120,12 +119,12 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^\,\)]*)*\\)[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")

if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile}
)
ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
set_property(
DIRECTORY
APPEND
PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile}
)
endif()

# check CMP0110 policy for new add_test() behavior
Expand Down Expand Up @@ -183,8 +182,8 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
string(REPLACE "]" ";" Tags "${Tags}")
string(REPLACE "[" "" Tags "${Tags}")
else()
# unset tags variable from previous loop
unset(Tags)
# unset tags variable from previous loop
unset(Tags)
endif()

list(APPEND Labels ${Tags})
Expand All @@ -208,7 +207,7 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
# Escape commas in the test spec
string(REPLACE "," "\\," Name ${Name})

# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary,
# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were necessary,
# only with CMake 3.18.0 the escaped double quotes confuse the call. This change is reverted in 3.18.1
# And properly introduced in 3.19 with the CMP0110 policy
if(_cmp0110_value STREQUAL "NEW" OR ${CMAKE_VERSION} VERSION_EQUAL "3.18")
Expand All @@ -220,7 +219,7 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)

# Handle template test cases
if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*")
set(Name "${Name} - *")
set(Name "${Name} - *")
endif()

# Escape double-quoting in CTestName due to above cmp0110
Expand All @@ -235,28 +234,32 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
)
# GENNY CHANGE: ADDED THE --reporter LINE


# Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8")
ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property")
set_tests_properties("${CTestName}" PROPERTIES DISABLED ON)
else()
set_tests_properties("${CTestName}" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
LABELS "${Labels}")
LABELS "${Labels}")
endif()
set_property(
TARGET ${TestTarget}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
TARGET ${TestTarget}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
set_property(
SOURCE ${SourceFile}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
SOURCE ${SourceFile}
APPEND
PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}")
endif()


endforeach()
endfunction()

# entry point
function(ParseAndAddCatchTests TestTarget)
message(DEPRECATION "ParseAndAddCatchTest: function deprecated because of possibility of missed test cases. Consider using 'catch_discover_tests' from 'Catch.cmake'")
ParseAndAddCatchTests_PrintDebugMessage("Started parsing ${TestTarget}")
get_target_property(SourceFiles ${TestTarget} SOURCES)
ParseAndAddCatchTests_PrintDebugMessage("Found the following sources: ${SourceFiles}")
Expand All @@ -265,3 +268,4 @@ function(ParseAndAddCatchTests TestTarget)
endforeach()
ParseAndAddCatchTests_PrintDebugMessage("Finished parsing ${TestTarget}")
endfunction()

6 changes: 3 additions & 3 deletions evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ buildvariants:
tasks:
- name: tg_compile

- name: macos-1014
display_name: macOS Mojave
- name: macos-1100
display_name: MacOS Big Sur
modules: [mongo]
run_on:
- macos-1014
- macos-1100
tasks:
- name: tg_compile

Expand Down
4 changes: 3 additions & 1 deletion src/canaries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ CreateGennyTargets(
metrics
Boost::program_options
Boost::filesystem
TEST_DEPENDS testlib
TEST_DEPENDS
testlib
Catch2::Catch2WithMain
EXECUTABLE genny-canaries
)
4 changes: 3 additions & 1 deletion src/cast_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ CreateGennyTargets(
gennylib
cppcodec::cppcodec
simple-beast-client
TEST_DEPENDS testlib
TEST_DEPENDS
testlib
Catch2::Catch2WithMain
)
4 changes: 2 additions & 2 deletions src/cast_core/src/MoveRandomChunkToRandomShard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void MoveRandomChunkToRandomShard::run() {
auto collectionDocOpt =
configDatabase["collections"].find_one(collectionFilter.view());
// There must be a collection with the provided namespace.
assert(collectionDocOpt.is_initialized());
auto uuid = collectionDocOpt.get().view()["uuid"].get_binary();
assert(collectionDocOpt);
auto uuid = collectionDocOpt->view()["uuid"].get_binary();

// Select a random chunk.
bsoncxx::document::value uuidDoc = bsoncxx::builder::stream::document()
Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/src/RollingCollections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct Read : public RunOperation {
_filterExpr ? _filterExpr->evaluate() : bsoncxx::document::view_or_value{};
auto optionalDocument = collection.find_one(filter);
if (optionalDocument) {
auto document = optionalDocument.get();
auto document = *optionalDocument;
statTracker.addDocuments(1);
statTracker.addBytes(document.view().length());
statTracker.success();
Expand Down
2 changes: 1 addition & 1 deletion src/cast_core/test/AssertiveActor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class AssertiveActorTestFixture : public MongoTestFixture {
try {
genny::ActorHelper ah = setupAssertActor(actorName, ignoreFields);
ah.run([](const genny::WorkloadContext& wc) { wc.actors()[0]->run(); });
INFO("Assert passed")
INFO("Assert passed");
} catch (const genny::actor::FailedAssertionException& e) {
// Did not expect assert to reach here.
auto diagInfo = boost::diagnostic_information(e);
Expand Down
4 changes: 3 additions & 1 deletion src/cast_core/test/CollectionScanner_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include <testlib/helpers.hpp>
#include <yaml-cpp/yaml.h>

#include <catch2/matchers/catch_matchers_string.hpp>

#include <boost/exception/diagnostic_information.hpp>

#include <bsoncxx/json.hpp>
Expand Down Expand Up @@ -295,7 +297,7 @@ TEST_CASE_METHOD(MongoTestFixture, "CollectionScannerGenerateCollectionNames", "

// Invalid generate collection names config with missing count.
REQUIRE_THROWS_WITH(testOneActor(config2, 5, ""),
Catch::Contains("CollectionCount must be greater than 0 when GenerateCollectionNames is true"));
Catch::Matchers::ContainsSubstring("CollectionCount must be greater than 0 when GenerateCollectionNames is true"));

} catch (const std::exception& e) {
auto diagInfo = boost::diagnostic_information(e);
Expand Down
5 changes: 3 additions & 2 deletions src/cast_core/test/CrudActorYamlTestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include <vector>
#include <string_view>

#include <boost/algorithm/string/trim.hpp>
#include <boost/exception/detail/exception_ptr.hpp>
Expand Down Expand Up @@ -107,7 +108,7 @@ void requireEvent(ApmEvent& event, YAML::Node requirements) {
if (isNumeric(w)) {
REQUIRE(event.command["writeConcern"]["w"].get_int32() == w.as<int32_t>());
} else {
REQUIRE(event.command["writeConcern"]["w"].get_utf8().value == w.as<std::string>());
REQUIRE(bsoncxx::stdx::string_view(w.as<std::string>()) == event.command["writeConcern"]["w"].get_utf8().value);
}
}
if (auto j = requirements["writeConcern"]["j"]; j) {
Expand All @@ -124,7 +125,7 @@ void requireEvent(ApmEvent& event, YAML::Node requirements) {
}
if (auto readPref = requirements["$readPreference"]["mode"]; readPref) {
REQUIRE(event.command["$readPreference"]["mode"].get_utf8().value ==
readPref.as<std::string>());
bsoncxx::stdx::string_view(readPref.as<std::string>()));
}
if (auto staleness = requirements["$readPreference"]["maxStalenessSeconds"]) {
REQUIRE(event.command["$readPreference"]["maxStalenessSeconds"].get_int64() ==
Expand Down
12 changes: 6 additions & 6 deletions src/cast_core/test/MoveRandomChunkToRandomShard_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ TEST_CASE_METHOD(MongoTestFixture,
<< "_id"
<< "test.collection0" << bsoncxx::builder::stream::finalize;
auto collectionDocOpt = configDatabase["collections"].find_one(collectionFilter.view());
REQUIRE(collectionDocOpt.is_initialized());
auto uuid = collectionDocOpt.get().view()["uuid"].get_binary();
REQUIRE(collectionDocOpt);
auto uuid = collectionDocOpt->view()["uuid"].get_binary();

// Get the chunk information, the lower bound (for comparison) and the shard id.
bsoncxx::document::value uuidDoc = bsoncxx::builder::stream::document()
Expand All @@ -94,9 +94,9 @@ TEST_CASE_METHOD(MongoTestFixture,
// There is only one chunk, store the initial shard id.
auto chunkOpt =
configDatabase["chunks"].find_one(chunksFilter.view(), chunkFindOptions);
REQUIRE(chunkOpt.is_initialized());
REQUIRE(chunkOpt);

auto initialShardId = chunkOpt.get().view()["shard"].get_utf8().value.to_string();
auto initialShardId = chunkOpt->view()["shard"].get_utf8().value.to_string();

// Run the actor.
genny::ActorHelper ah(nodes.root(), 1);
Expand All @@ -106,9 +106,9 @@ TEST_CASE_METHOD(MongoTestFixture,
auto afterMigrationChunkOpt =
configDatabase["chunks"].find_one(chunksFilter.view(), chunkFindOptions);

REQUIRE(afterMigrationChunkOpt.is_initialized());
REQUIRE(afterMigrationChunkOpt);
auto finalShardId =
afterMigrationChunkOpt.get().view()["shard"].get_utf8().value.to_string();
afterMigrationChunkOpt->view()["shard"].get_utf8().value.to_string();

REQUIRE(initialShardId != finalShardId);
} catch (const std::exception& e) {
Expand Down
Loading