Changeset View
Changeset View
Standalone View
Standalone View
src/test/main.cpp
// Copyright (c) 2011-2016 The Bitcoin Core developers | // Copyright (c) 2011-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#define BOOST_TEST_MODULE Bitcoin ABC unit tests | #define BOOST_TEST_MODULE Bitcoin ABC unit tests | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <test/util/setup_common.h> | |||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
static std::set<std::string> customArguments{ | |||||
"-testsuitename", | |||||
"-axionactivationtime", | |||||
}; | |||||
void AddCustomArguments(const std::set<std::string> &arguments) { | |||||
customArguments.insert(arguments.begin(), arguments.end()); | |||||
} | |||||
namespace utf = boost::unit_test::framework; | namespace utf = boost::unit_test::framework; | ||||
/* | /* | ||||
* Global fixture for passing custom arguments, and clearing them all after each | * Global fixture for passing custom arguments, and clearing them all after each | ||||
* test case. | * test case. | ||||
*/ | */ | ||||
struct CustomArgumentsFixture { | struct CustomArgumentsFixture { | ||||
std::string error; | std::string error; | ||||
CustomArgumentsFixture() { | CustomArgumentsFixture() { | ||||
const std::string testsuitename = "-testsuitename"; | for (const auto &arg : customArguments) { | ||||
const std::set<std::string> testArgs = { | |||||
testsuitename, | |||||
"-axionactivationtime", | |||||
}; | |||||
for (const auto &arg : testArgs) { | |||||
gArgs.AddArg(arg, "", ArgsManager::ALLOW_ANY, | gArgs.AddArg(arg, "", ArgsManager::ALLOW_ANY, | ||||
OptionsCategory::HIDDEN); | OptionsCategory::HIDDEN); | ||||
} | } | ||||
auto &master_test_suite = utf::master_test_suite(); | auto &master_test_suite = utf::master_test_suite(); | ||||
if (!gArgs.ParseParameters(master_test_suite.argc, | if (!gArgs.ParseParameters(master_test_suite.argc, | ||||
master_test_suite.argv, error)) { | master_test_suite.argv, error)) { | ||||
throw utf::setup_error(error); | throw utf::setup_error(error); | ||||
} | } | ||||
master_test_suite.p_name.value = | master_test_suite.p_name.value = | ||||
gArgs.GetArg(testsuitename, master_test_suite.p_name.value); | gArgs.GetArg("-testsuitename", master_test_suite.p_name.value); | ||||
} | } | ||||
~CustomArgumentsFixture(){}; | ~CustomArgumentsFixture(){}; | ||||
}; | }; | ||||
BOOST_GLOBAL_FIXTURE(CustomArgumentsFixture); | BOOST_GLOBAL_FIXTURE(CustomArgumentsFixture); |