mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use Boost::Program_Options in soltest
This commit is contained in:
parent
f4110b295b
commit
8b342cbe6a
@ -30,7 +30,7 @@ add_executable(soltest ${sources} ${headers}
|
|||||||
${libsolidity_sources} ${libsolidity_headers}
|
${libsolidity_sources} ${libsolidity_headers}
|
||||||
${libsolidity_util_sources} ${libsolidity_util_headers}
|
${libsolidity_util_sources} ${libsolidity_util_headers}
|
||||||
)
|
)
|
||||||
target_link_libraries(soltest PRIVATE libsolc yul solidity evmasm devcore ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
|
target_link_libraries(soltest PRIVATE libsolc yul solidity evmasm devcore ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
|
||||||
|
|
||||||
if (LLL)
|
if (LLL)
|
||||||
target_link_libraries(soltest PRIVATE lll)
|
target_link_libraries(soltest PRIVATE lll)
|
||||||
|
@ -28,10 +28,12 @@
|
|||||||
|
|
||||||
#include <boost/test/framework.hpp>
|
#include <boost/test/framework.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev::test;
|
using namespace dev::test;
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
Options const& Options::get()
|
Options const& Options::get()
|
||||||
{
|
{
|
||||||
@ -42,39 +44,42 @@ Options const& Options::get()
|
|||||||
Options::Options()
|
Options::Options()
|
||||||
{
|
{
|
||||||
auto const& suite = boost::unit_test::framework::master_test_suite();
|
auto const& suite = boost::unit_test::framework::master_test_suite();
|
||||||
for (auto i = 0; i < suite.argc; i++)
|
|
||||||
if (string(suite.argv[i]) == "--ipcpath" && i + 1 < suite.argc)
|
|
||||||
{
|
|
||||||
ipcPath = suite.argv[i + 1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else if (string(suite.argv[i]) == "--testpath" && i + 1 < suite.argc)
|
|
||||||
{
|
|
||||||
testPath = suite.argv[i + 1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else if (string(suite.argv[i]) == "--optimize")
|
|
||||||
optimize = true;
|
|
||||||
else if (string(suite.argv[i]) == "--abiencoderv2")
|
|
||||||
useABIEncoderV2 = true;
|
|
||||||
else if (string(suite.argv[i]) == "--evm-version")
|
|
||||||
{
|
|
||||||
evmVersionString = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID";
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
else if (string(suite.argv[i]) == "--show-messages")
|
|
||||||
showMessages = true;
|
|
||||||
else if (string(suite.argv[i]) == "--no-ipc")
|
|
||||||
disableIPC = true;
|
|
||||||
else if (string(suite.argv[i]) == "--no-smt")
|
|
||||||
disableSMT = true;
|
|
||||||
|
|
||||||
if (!disableIPC && ipcPath.empty())
|
if (suite.argc == 0)
|
||||||
if (auto path = getenv("ETH_TEST_IPC"))
|
return;
|
||||||
ipcPath = path;
|
|
||||||
|
|
||||||
if (testPath.empty())
|
po::options_description options("",
|
||||||
testPath = getTestPath();
|
po::options_description::m_default_line_length,
|
||||||
|
po::options_description::m_default_line_length - 23);
|
||||||
|
|
||||||
|
options.add_options()
|
||||||
|
("testpath", po::value<fs::path>(&testPath)->default_value(getTestPath()), "path to test files")
|
||||||
|
("ipcpath", po::value<string>(&ipcPath)->default_value(getenv("ETH_TEST_IPC")), "path to ipc socket")
|
||||||
|
("no-ipc", po::bool_switch(&disableIPC), "disable semantic tests")
|
||||||
|
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker")
|
||||||
|
("optimize", po::bool_switch(&optimize), "enables optimization")
|
||||||
|
("abiencoderv2", po::bool_switch(&useABIEncoderV2), "enables abi encoder v2")
|
||||||
|
("evm-version", po::value(&evmVersionString), "which evm version to use")
|
||||||
|
("show-messages", po::bool_switch(&showMessages), "enables message output");
|
||||||
|
|
||||||
|
po::variables_map arguments;
|
||||||
|
|
||||||
|
po::command_line_parser cmdLineParser(suite.argc, suite.argv);
|
||||||
|
cmdLineParser.options(options);
|
||||||
|
po::store(cmdLineParser.run(), arguments);
|
||||||
|
po::notify(arguments);
|
||||||
|
|
||||||
|
if (!disableIPC)
|
||||||
|
{
|
||||||
|
solAssert(
|
||||||
|
!ipcPath.empty(),
|
||||||
|
"No ipc path specified. The --ipcpath argument is required, unless --no-ipc is used."
|
||||||
|
);
|
||||||
|
solAssert(
|
||||||
|
fs::exists(ipcPath),
|
||||||
|
"Invalid ipc path specified."
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::validate() const
|
void Options::validate() const
|
||||||
|
Loading…
Reference in New Issue
Block a user