|
20 | 20 | #include <iostream>
|
21 | 21 | #include <test/Common.h>
|
22 | 22 | #include <test/EVMHost.h>
|
| 23 | +#include <test/libsolidity/util/SoltestErrors.h> |
23 | 24 |
|
24 | 25 | #include <libsolutil/Assertions.h>
|
| 26 | +#include <libsolutil/StringUtils.h> |
25 | 27 | #include <boost/algorithm/string.hpp>
|
26 | 28 | #include <boost/filesystem.hpp>
|
27 | 29 | #include <boost/program_options.hpp>
|
| 30 | +#include <range/v3/all.hpp> |
28 | 31 |
|
29 | 32 | namespace fs = boost::filesystem;
|
30 | 33 | namespace po = boost::program_options;
|
31 | 34 |
|
| 35 | +using namespace std; |
| 36 | + |
32 | 37 | namespace solidity::test
|
33 | 38 | {
|
34 | 39 |
|
@@ -207,6 +212,41 @@ bool CommonOptions::parse(int argc, char const* const* argv)
|
207 | 212 | return true;
|
208 | 213 | }
|
209 | 214 |
|
| 215 | +string CommonOptions::toString(vector<string> const& _selectedOptions) const |
| 216 | +{ |
| 217 | + if (_selectedOptions.empty()) |
| 218 | + return ""; |
| 219 | + |
| 220 | + auto boolToString = [](bool _value) -> string { return _value ? "true" : "false"; }; |
| 221 | + // Using std::map to avoid if-else/switch-case block |
| 222 | + map<string, string> optionValueMap = { |
| 223 | + {"evmVersion", evmVersion().name()}, |
| 224 | + {"optimize", boolToString(optimize)}, |
| 225 | + {"useABIEncoderV1", boolToString(useABIEncoderV1)}, |
| 226 | + {"batch", to_string(selectedBatch + 1) + "/" + to_string(batches)}, |
| 227 | + {"ewasm", boolToString(ewasm)}, |
| 228 | + {"enforceCompileToEwasm", boolToString(enforceCompileToEwasm)}, |
| 229 | + {"enforceGasTest", boolToString(enforceGasTest)}, |
| 230 | + {"enforceGasTestMinValue", enforceGasTestMinValue.str()}, |
| 231 | + {"disableSemanticTests", boolToString(disableSemanticTests)}, |
| 232 | + {"disableSMT", boolToString(disableSMT)}, |
| 233 | + {"showMessages", boolToString(showMessages)}, |
| 234 | + {"showMetadata", boolToString(showMetadata)} |
| 235 | + }; |
| 236 | + |
| 237 | + soltestAssert(ranges::all_of(_selectedOptions, [&optionValueMap](string const& _option) { return optionValueMap.count(_option) > 0; })); |
| 238 | + |
| 239 | + vector<string> optionsWithValues = _selectedOptions | |
| 240 | + ranges::views::transform([&optionValueMap](string const& _option) { return _option + "=" + optionValueMap.at(_option); }) | |
| 241 | + ranges::to<vector>(); |
| 242 | + |
| 243 | + return solidity::util::joinHumanReadable(optionsWithValues); |
| 244 | +} |
| 245 | + |
| 246 | +void CommonOptions::printSelectedOptions(ostream& _stream, string const& _linePrefix, vector<string> const& _selectedOptions) const |
| 247 | +{ |
| 248 | + _stream << _linePrefix << "Run Settings: " << toString(_selectedOptions) << endl; |
| 249 | +} |
210 | 250 |
|
211 | 251 | langutil::EVMVersion CommonOptions::evmVersion() const
|
212 | 252 | {
|
|
0 commit comments