Merge pull request #6916 from ethereum/alsoViaYul

Allow extracted semantics tests to run with and without yul.
This commit is contained in:
Daniel Kirchner 2019-06-06 21:05:52 +02:00 committed by GitHub
commit a4087d4b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 55 deletions

View File

@ -45,9 +45,19 @@ SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, lang
m_source = parseSourceAndSettings(file);
if (m_settings.count("compileViaYul"))
{
if (m_settings["compileViaYul"] == "also")
{
m_validatedSettings["compileViaYul"] = m_settings["compileViaYul"];
m_compileViaYul = true;
m_runWithYul = true;
m_runWithoutYul = true;
}
else
{
m_validatedSettings["compileViaYul"] = "only";
m_runWithYul = true;
m_runWithoutYul = false;
}
m_settings.erase("compileViaYul");
}
parseExpectations(file);
@ -55,9 +65,14 @@ SemanticTest::SemanticTest(string const& _filename, string const& _ipcPath, lang
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
for(bool compileViaYul: set<bool>{!m_runWithoutYul, m_runWithYul})
{
bool success = true;
m_compileViaYul = compileViaYul;
if (compileViaYul)
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Running via Yul:" << endl;
for (auto& test: m_tests)
test.reset();
@ -115,8 +130,19 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref
}
AnsiColorized(_stream, _formatted, {BOLD, RED}) << _linePrefix << endl << _linePrefix
<< "Attention: Updates on the test will apply the detected format displayed." << endl;
if (compileViaYul && m_runWithoutYul)
{
_stream << _linePrefix << endl << _linePrefix;
AnsiColorized(_stream, _formatted, {RED_BACKGROUND}) << "Note that the test passed without Yul.";
_stream << endl;
}
else if (!compileViaYul && m_runWithYul)
AnsiColorized(_stream, _formatted, {BOLD, YELLOW}) << _linePrefix << endl << _linePrefix
<< "Note that the test also has to pass via Yul." << endl;
return TestResult::Failure;
}
}
return TestResult::Success;
}

View File

@ -65,6 +65,8 @@ public:
private:
std::string m_source;
std::vector<TestFunctionCall> m_tests;
bool m_runWithYul = false;
bool m_runWithoutYul = true;
};
}