mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1719 from ethereum/fuzzerLine
Filter fuzzing errors by cause.
This commit is contained in:
commit
6ac2c15c2b
@ -41,6 +41,9 @@ struct Exception: virtual std::exception, virtual boost::exception
|
||||
Exception(std::string _message = std::string()): m_message(std::move(_message)) {}
|
||||
const char* what() const noexcept override { return m_message.empty() ? std::exception::what() : m_message.c_str(); }
|
||||
|
||||
/// @returns "FileName:LineNumber" referring to the point where the exception was thrown.
|
||||
std::string lineInfo() const;
|
||||
|
||||
private:
|
||||
std::string m_message;
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <libsolidity/interface/Exceptions.h>
|
||||
#include <libsolidity/interface/Utils.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::solidity;
|
||||
|
||||
@ -56,3 +57,16 @@ Error::Error(Type _type): m_type(_type)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string Exception::lineInfo() const
|
||||
{
|
||||
char const* const* file = boost::get_error_info<boost::throw_file>(*this);
|
||||
int const* line = boost::get_error_info<boost::throw_line>(*this);
|
||||
string ret;
|
||||
if (file)
|
||||
ret += *file;
|
||||
ret += ':';
|
||||
if (line)
|
||||
ret += boost::lexical_cast<string>(*line);
|
||||
return ret;
|
||||
}
|
||||
|
14
scripts/uniqueErrors.sh
Executable file
14
scripts/uniqueErrors.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
REPO=$(dirname $0)/..
|
||||
|
||||
echo "Finding unique failures..."
|
||||
(
|
||||
for x in $*
|
||||
do
|
||||
echo -n $x " # "
|
||||
# This subshell is a workaround to prevent the shell from printing
|
||||
# "Aborted"
|
||||
("$REPO"/build/test/solfuzzer < "$x" || true) 2>&1 | head -n 1
|
||||
done
|
||||
) | sort -u -t'#' -k 2
|
@ -184,15 +184,15 @@ string compile(StringMap const& _sources, bool _optimize, CStyleReadFileCallback
|
||||
}
|
||||
catch (CompilerError const& exception)
|
||||
{
|
||||
errors.append(formatError(exception, "Compiler error", scannerFromSourceName));
|
||||
errors.append(formatError(exception, "Compiler error (" + exception.lineInfo() + ")", scannerFromSourceName));
|
||||
}
|
||||
catch (InternalCompilerError const& exception)
|
||||
{
|
||||
errors.append(formatError(exception, "Internal compiler error", scannerFromSourceName));
|
||||
errors.append(formatError(exception, "Internal compiler error (" + exception.lineInfo() + ")", scannerFromSourceName));
|
||||
}
|
||||
catch (UnimplementedFeatureError const& exception)
|
||||
{
|
||||
errors.append(formatError(exception, "Unimplemented feature", scannerFromSourceName));
|
||||
errors.append(formatError(exception, "Unimplemented feature (" + exception.lineInfo() + ")", scannerFromSourceName));
|
||||
}
|
||||
catch (Exception const& exception)
|
||||
{
|
||||
|
@ -67,7 +67,6 @@ int main()
|
||||
for (Json::Value const& error: outputJson["errors"])
|
||||
{
|
||||
string invalid = contains(error.asString(), vector<string>{
|
||||
"Compiler error",
|
||||
"Internal compiler error",
|
||||
"Exception during compilation",
|
||||
"Unknown exception during compilation",
|
||||
@ -78,7 +77,7 @@ int main()
|
||||
});
|
||||
if (!invalid.empty())
|
||||
{
|
||||
cout << "Invalid error: \"" << invalid << "\"" << endl;
|
||||
cout << "Invalid error: \"" << error.asString() << "\"" << endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user