Merge pull request #5966 from ethereum/AnsiColorized

Adapts tests/ to use AnsiColorized (the generalized/moved version of FormattedScope, which in turn is removed in this PR)
This commit is contained in:
chriseth
2019-02-11 16:41:14 +01:00
committed by GitHub
9 changed files with 43 additions and 109 deletions
+7 -7
View File
@@ -17,8 +17,6 @@
#include <test/libyul/YulOptimizerTest.h>
#include <test/libsolidity/FormattedScope.h>
#include <test/Options.h>
#include <libyul/optimiser/BlockFlattener.h>
@@ -53,6 +51,8 @@
#include <liblangutil/ErrorReporter.h>
#include <liblangutil/Scanner.h>
#include <libdevcore/AnsiColorized.h>
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>
@@ -253,7 +253,7 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
OptimiserSuite::run(m_dialect, *m_ast, *m_analysisInfo);
else
{
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Invalid optimizer step: " << m_optimizerStep << endl;
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Invalid optimizer step: " << m_optimizerStep << endl;
return false;
}
@@ -262,10 +262,10 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
if (m_expectation != m_obtainedResult)
{
string nextIndentLevel = _linePrefix + " ";
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Expected result:" << endl;
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Expected result:" << endl;
// TODO could compute a simple diff with highlighted lines
printIndented(_stream, m_expectation, nextIndentLevel);
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl;
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl;
printIndented(_stream, m_obtainedResult, nextIndentLevel);
return false;
}
@@ -299,7 +299,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c
m_ast = yul::Parser(errorReporter, m_dialect).parse(scanner, false);
if (!m_ast || !errorReporter.errors().empty())
{
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error parsing source." << endl;
printErrors(_stream, errorReporter.errors());
return false;
}
@@ -313,7 +313,7 @@ bool YulOptimizerTest::parse(ostream& _stream, string const& _linePrefix, bool c
);
if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty())
{
FormattedScope(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error analyzing source." << endl;
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::RED}) << _linePrefix << "Error analyzing source." << endl;
printErrors(_stream, errorReporter.errors());
return false;
}