mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #13075 from ethereum/add-more-info-to-failed-semantic-tests
Print settings options such evmVersion and optimize in isoltest/soltest failed test logs.
This commit is contained in:
commit
80f6a13d65
@ -20,15 +20,20 @@
|
||||
#include <iostream>
|
||||
#include <test/Common.h>
|
||||
#include <test/EVMHost.h>
|
||||
#include <test/libsolidity/util/SoltestErrors.h>
|
||||
|
||||
#include <libsolutil/Assertions.h>
|
||||
#include <libsolutil/StringUtils.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
#include <range/v3/all.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::test
|
||||
{
|
||||
|
||||
@ -207,6 +212,41 @@ bool CommonOptions::parse(int argc, char const* const* argv)
|
||||
return true;
|
||||
}
|
||||
|
||||
string CommonOptions::toString(vector<string> const& _selectedOptions) const
|
||||
{
|
||||
if (_selectedOptions.empty())
|
||||
return "";
|
||||
|
||||
auto boolToString = [](bool _value) -> string { return _value ? "true" : "false"; };
|
||||
// Using std::map to avoid if-else/switch-case block
|
||||
map<string, string> optionValueMap = {
|
||||
{"evmVersion", evmVersion().name()},
|
||||
{"optimize", boolToString(optimize)},
|
||||
{"useABIEncoderV1", boolToString(useABIEncoderV1)},
|
||||
{"batch", to_string(selectedBatch + 1) + "/" + to_string(batches)},
|
||||
{"ewasm", boolToString(ewasm)},
|
||||
{"enforceCompileToEwasm", boolToString(enforceCompileToEwasm)},
|
||||
{"enforceGasTest", boolToString(enforceGasTest)},
|
||||
{"enforceGasTestMinValue", enforceGasTestMinValue.str()},
|
||||
{"disableSemanticTests", boolToString(disableSemanticTests)},
|
||||
{"disableSMT", boolToString(disableSMT)},
|
||||
{"showMessages", boolToString(showMessages)},
|
||||
{"showMetadata", boolToString(showMetadata)}
|
||||
};
|
||||
|
||||
soltestAssert(ranges::all_of(_selectedOptions, [&optionValueMap](string const& _option) { return optionValueMap.count(_option) > 0; }));
|
||||
|
||||
vector<string> optionsWithValues = _selectedOptions |
|
||||
ranges::views::transform([&optionValueMap](string const& _option) { return _option + "=" + optionValueMap.at(_option); }) |
|
||||
ranges::to<vector>();
|
||||
|
||||
return solidity::util::joinHumanReadable(optionsWithValues);
|
||||
}
|
||||
|
||||
void CommonOptions::printSelectedOptions(ostream& _stream, string const& _linePrefix, vector<string> const& _selectedOptions) const
|
||||
{
|
||||
_stream << _linePrefix << "Run Settings: " << toString(_selectedOptions) << endl;
|
||||
}
|
||||
|
||||
langutil::EVMVersion CommonOptions::evmVersion() const
|
||||
{
|
||||
|
@ -81,6 +81,12 @@ struct CommonOptions
|
||||
// Throws a ConfigException on error
|
||||
virtual void validate() const;
|
||||
|
||||
/// @returns string with a key=value list of the options separated by comma
|
||||
/// Ex.: "evmVersion=london, optimize=true, useABIEncoderV1=false"
|
||||
virtual std::string toString(std::vector<std::string> const& _selectedOptions) const;
|
||||
/// Helper to print the value of settings used
|
||||
virtual void printSelectedOptions(std::ostream& _stream, std::string const& _linePrefix, std::vector<std::string> const& _selectedOptions) const;
|
||||
|
||||
static CommonOptions const& get();
|
||||
static void setSingleton(std::unique_ptr<CommonOptions const>&& _instance);
|
||||
|
||||
|
@ -315,6 +315,14 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != TestResult::Success)
|
||||
solidity::test::CommonOptions::get().printSelectedOptions(
|
||||
_stream,
|
||||
_linePrefix,
|
||||
{"evmVersion", "optimize", "useABIEncoderV1", "batch"}
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user