diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-04-26 07:05:39 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-08 22:45:08 +0000 |
commit | 7c51aca7fd085ead0ae3e19d967ff1abf111d13a (patch) | |
tree | becfe057d3dbbb88b02ad628fb1a95a30adf686c /src/mongo/unittest | |
parent | 987484b4aa34deea1db7d70228989b83448a24e8 (diff) | |
download | mongo-7c51aca7fd085ead0ae3e19d967ff1abf111d13a.tar.gz |
SERVER-40811 make initializers throwy
- Consolidate init-related headers (just init.h and initializer.h)
- Factor out a separate DependencyGraph component
- Remove MONGO_DEFAULT_PREREQUISITES, MONGO_NO_PREREQUISITES, MONGO_NO_DEPENDENTS.
- Document the role of the "default" initializer.
Diffstat (limited to 'src/mongo/unittest')
-rw-r--r-- | src/mongo/unittest/integration_test_main.cpp | 31 | ||||
-rw-r--r-- | src/mongo/unittest/temp_dir.cpp | 13 | ||||
-rw-r--r-- | src/mongo/unittest/unittest_main.cpp | 1 |
3 files changed, 11 insertions, 34 deletions
diff --git a/src/mongo/unittest/integration_test_main.cpp b/src/mongo/unittest/integration_test_main.cpp index 6fb5a68fb5e..43173c361b9 100644 --- a/src/mongo/unittest/integration_test_main.cpp +++ b/src/mongo/unittest/integration_test_main.cpp @@ -63,7 +63,6 @@ ConnectionString fixtureConnectionString{}; MONGO_INITIALIZER(WireSpec)(InitializerContext*) { WireSpec::instance().initialize(WireSpec::Specification{}); - return Status::OK(); } } // namespace @@ -95,60 +94,40 @@ MONGO_INITIALIZER_GENERAL(ForkServer, ("EndStartupOptionHandling"), ("default")) (InitializerContext* context) { // Integration tests do not fork, however the init graph requires a deliberate initializer that // _could_ fork and here choses not to do so. - return Status::OK(); } MONGO_GENERAL_STARTUP_OPTIONS_REGISTER(IntegrationTestOptions)(InitializerContext*) { uassertStatusOK(addBaseServerOptions(&moe::startupOptions)); - - return Status::OK(); } MONGO_STARTUP_OPTIONS_VALIDATE(IntegrationTestOptions)(InitializerContext*) { auto& env = moe::startupOptionsParsed; auto& opts = moe::startupOptions; - if (auto ret = env.validate(); !ret.isOK()) { - return ret; - } - - if (auto ret = validateBaseOptions(env); !ret.isOK()) { - return ret; - } + uassertStatusOK(env.validate()); + uassertStatusOK(validateBaseOptions(env)); if (env.count("help")) { std::cout << opts.helpString() << std::endl; quickExit(EXIT_SUCCESS); } - - return Status::OK(); } MONGO_STARTUP_OPTIONS_STORE(IntegrationTestOptions)(InitializerContext*) { auto& env = moe::startupOptionsParsed; - if (auto ret = canonicalizeBaseOptions(&env); !ret.isOK()) { - return ret; - } - - if (auto ret = storeBaseOptions(env); !ret.isOK()) { - return ret; - } + uassertStatusOK(canonicalizeBaseOptions(&env)); + uassertStatusOK(storeBaseOptions(env)); std::string connectionString = env["connectionString"].as<std::string>(); auto swConnectionString = ConnectionString::parse(connectionString); - if (!swConnectionString.isOK()) { - return swConnectionString.getStatus(); - } + uassertStatusOK(swConnectionString); fixtureConnectionString = std::move(swConnectionString.getValue()); LOGV2(23050, "Using test fixture with connection string = {connectionString}", "connectionString"_attr = connectionString); - - - return Status::OK(); } } // namespace diff --git a/src/mongo/unittest/temp_dir.cpp b/src/mongo/unittest/temp_dir.cpp index ab8ec61f548..88b274883f9 100644 --- a/src/mongo/unittest/temp_dir.cpp +++ b/src/mongo/unittest/temp_dir.cpp @@ -61,17 +61,16 @@ MONGO_INITIALIZER(SetTempDirDefaultRoot)(InitializerContext* context) { } if (!boost::filesystem::exists(defaultRoot)) { - return Status(ErrorCodes::BadValue, - str::stream() << "Attempted to use a tempPath (" << defaultRoot.string() - << ") that doesn't exist"); + uasserted(ErrorCodes::BadValue, + str::stream() << "Attempted to use a tempPath (" << defaultRoot.string() + << ") that doesn't exist"); } if (!boost::filesystem::is_directory(defaultRoot)) { - return Status(ErrorCodes::BadValue, - str::stream() << "Attempted to use a tempPath (" << defaultRoot.string() - << ") that exists, but isn't a directory"); + uasserted(ErrorCodes::BadValue, + str::stream() << "Attempted to use a tempPath (" << defaultRoot.string() + << ") that exists, but isn't a directory"); } - return Status::OK(); } } // namespace diff --git a/src/mongo/unittest/unittest_main.cpp b/src/mongo/unittest/unittest_main.cpp index 1056198a04f..f64d8d4d688 100644 --- a/src/mongo/unittest/unittest_main.cpp +++ b/src/mongo/unittest/unittest_main.cpp @@ -56,7 +56,6 @@ namespace { MONGO_INITIALIZER(WireSpec)(InitializerContext*) { WireSpec::instance().initialize(WireSpec::Specification{}); - return Status::OK(); } } // namespace |