2018-03-14 18:15:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of solidity.
|
|
|
|
|
|
|
|
solidity is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
solidity is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-01-06 10:52:23 +00:00
|
|
|
#include <libsolutil/CommonIO.h>
|
|
|
|
#include <libsolutil/AnsiColorized.h>
|
2018-10-10 14:12:18 +00:00
|
|
|
|
2020-01-14 16:48:17 +00:00
|
|
|
#include <memory>
|
2018-10-10 14:12:18 +00:00
|
|
|
#include <test/Common.h>
|
2019-02-19 16:34:59 +00:00
|
|
|
#include <test/tools/IsolTestOptions.h>
|
2018-03-14 18:15:48 +00:00
|
|
|
#include <test/libsolidity/AnalysisFramework.h>
|
2018-12-05 17:00:23 +00:00
|
|
|
#include <test/InteractiveTests.h>
|
2019-07-16 17:05:13 +00:00
|
|
|
#include <test/EVMHost.h>
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2018-03-16 10:40:03 +00:00
|
|
|
#include <boost/algorithm/string.hpp>
|
2018-03-14 18:15:48 +00:00
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
#include <boost/program_options.hpp>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <fstream>
|
2020-04-01 03:04:29 +00:00
|
|
|
#include <iostream>
|
2018-03-14 18:15:48 +00:00
|
|
|
#include <queue>
|
2019-04-10 14:09:32 +00:00
|
|
|
#include <regex>
|
2020-04-01 03:04:29 +00:00
|
|
|
#include <utility>
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2018-07-10 08:36:36 +00:00
|
|
|
#if defined(_WIN32)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2018-03-14 18:15:48 +00:00
|
|
|
using namespace std;
|
2019-12-23 15:50:30 +00:00
|
|
|
using namespace solidity;
|
|
|
|
using namespace solidity::util;
|
|
|
|
using namespace solidity::frontend;
|
|
|
|
using namespace solidity::frontend::test;
|
|
|
|
using namespace solidity::util::formatting;
|
|
|
|
|
2018-03-14 18:15:48 +00:00
|
|
|
namespace po = boost::program_options;
|
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
|
2019-04-10 21:00:47 +00:00
|
|
|
using TestCreator = TestCase::TestCaseCreator;
|
2019-12-23 15:50:30 +00:00
|
|
|
using TestOptions = solidity::test::IsolTestOptions;
|
2019-04-10 21:00:47 +00:00
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
struct TestStats
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2019-03-15 16:22:04 +00:00
|
|
|
int successCount = 0;
|
|
|
|
int testCount = 0;
|
|
|
|
int skippedCount = 0;
|
2019-03-18 13:08:56 +00:00
|
|
|
operator bool() const noexcept { return successCount + skippedCount == testCount; }
|
2018-10-10 14:12:18 +00:00
|
|
|
TestStats& operator+=(TestStats const& _other) noexcept
|
2018-10-09 13:36:40 +00:00
|
|
|
{
|
|
|
|
successCount += _other.successCount;
|
|
|
|
testCount += _other.testCount;
|
2019-03-15 16:22:04 +00:00
|
|
|
skippedCount += _other.skippedCount;
|
2018-10-09 13:36:40 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2018-03-14 18:15:48 +00:00
|
|
|
};
|
|
|
|
|
2019-04-10 14:09:32 +00:00
|
|
|
class TestFilter
|
|
|
|
{
|
|
|
|
public:
|
2020-04-01 03:04:29 +00:00
|
|
|
explicit TestFilter(string _filter): m_filter(std::move(_filter))
|
2019-04-10 14:09:32 +00:00
|
|
|
{
|
|
|
|
string filter{m_filter};
|
|
|
|
|
|
|
|
boost::replace_all(filter, "/", "\\/");
|
|
|
|
boost::replace_all(filter, "*", ".*");
|
|
|
|
|
|
|
|
m_filterExpression = regex{"(" + filter + "(\\.sol|\\.yul))"};
|
|
|
|
}
|
|
|
|
|
|
|
|
bool matches(string const& _name) const
|
|
|
|
{
|
|
|
|
return regex_match(_name, m_filterExpression);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
string m_filter;
|
|
|
|
regex m_filterExpression;
|
|
|
|
};
|
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
class TestTool
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-06-08 12:17:50 +00:00
|
|
|
TestTool(
|
2019-04-10 21:00:47 +00:00
|
|
|
TestCreator _testCaseCreator,
|
|
|
|
TestOptions const& _options,
|
2020-04-01 03:04:29 +00:00
|
|
|
fs::path _path,
|
|
|
|
string _name
|
2019-04-10 14:09:32 +00:00
|
|
|
):
|
|
|
|
m_testCaseCreator(_testCaseCreator),
|
2019-04-10 21:00:47 +00:00
|
|
|
m_options(_options),
|
2019-04-17 09:45:51 +00:00
|
|
|
m_filter(TestFilter{_options.testFilter}),
|
2020-04-01 03:04:29 +00:00
|
|
|
m_path(std::move(_path)),
|
|
|
|
m_name(std::move(_name))
|
2018-03-14 18:15:48 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
enum class Result
|
|
|
|
{
|
|
|
|
Success,
|
|
|
|
Failure,
|
2019-03-15 16:22:04 +00:00
|
|
|
Exception,
|
|
|
|
Skipped
|
2018-03-14 18:15:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Result process();
|
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
static TestStats processPath(
|
2019-04-10 21:00:47 +00:00
|
|
|
TestCreator _testCaseCreator,
|
|
|
|
TestOptions const& _options,
|
2018-03-14 18:15:48 +00:00
|
|
|
fs::path const& _basepath,
|
2019-04-10 21:00:47 +00:00
|
|
|
fs::path const& _path
|
2018-03-14 18:15:48 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static string editor;
|
|
|
|
private:
|
|
|
|
enum class Request
|
|
|
|
{
|
|
|
|
Skip,
|
|
|
|
Rerun,
|
|
|
|
Quit
|
|
|
|
};
|
|
|
|
|
2019-03-18 13:08:56 +00:00
|
|
|
Request handleResponse(bool _exception);
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2019-04-10 21:00:47 +00:00
|
|
|
TestCreator m_testCaseCreator;
|
|
|
|
TestOptions const& m_options;
|
2019-04-10 14:09:32 +00:00
|
|
|
TestFilter m_filter;
|
2018-03-14 18:15:48 +00:00
|
|
|
fs::path const m_path;
|
2019-04-10 21:00:47 +00:00
|
|
|
string const m_name;
|
2019-04-10 14:09:32 +00:00
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
unique_ptr<TestCase> m_test;
|
2019-04-10 14:09:32 +00:00
|
|
|
|
2018-08-07 17:28:21 +00:00
|
|
|
static bool m_exitRequested;
|
2018-03-14 18:15:48 +00:00
|
|
|
};
|
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
string TestTool::editor;
|
2018-08-07 17:28:21 +00:00
|
|
|
bool TestTool::m_exitRequested = false;
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
TestTool::Result TestTool::process()
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
bool formatted{!m_options.noColor};
|
2018-03-14 18:15:48 +00:00
|
|
|
std::stringstream outputMessages;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2019-04-10 14:09:32 +00:00
|
|
|
if (m_filter.matches(m_name))
|
2019-03-15 16:22:04 +00:00
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
(AnsiColorized(cout, formatted, {BOLD}) << m_name << ": ").flush();
|
2019-04-10 14:09:32 +00:00
|
|
|
|
2019-07-17 08:24:23 +00:00
|
|
|
m_test = m_testCaseCreator(TestCase::Config{m_path.string(), m_options.evmVersion()});
|
2020-02-18 16:13:13 +00:00
|
|
|
if (m_test->shouldRun())
|
2019-05-07 13:33:22 +00:00
|
|
|
switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted))
|
|
|
|
{
|
|
|
|
case TestCase::TestResult::Success:
|
|
|
|
AnsiColorized(cout, formatted, {BOLD, GREEN}) << "OK" << endl;
|
|
|
|
return Result::Success;
|
|
|
|
default:
|
|
|
|
AnsiColorized(cout, formatted, {BOLD, RED}) << "FAIL" << endl;
|
|
|
|
|
|
|
|
AnsiColorized(cout, formatted, {BOLD, CYAN}) << " Contract:" << endl;
|
|
|
|
m_test->printSource(cout, " ", formatted);
|
2020-03-19 01:48:42 +00:00
|
|
|
m_test->printSettings(cout, " ", formatted);
|
2019-05-07 13:33:22 +00:00
|
|
|
|
|
|
|
cout << endl << outputMessages.str() << endl;
|
|
|
|
return result == TestCase::TestResult::FatalError ? Result::Exception : Result::Failure;
|
|
|
|
}
|
2019-04-10 14:09:32 +00:00
|
|
|
else
|
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, YELLOW}) << "NOT RUN" << endl;
|
2019-04-10 14:09:32 +00:00
|
|
|
return Result::Skipped;
|
|
|
|
}
|
2019-03-15 16:22:04 +00:00
|
|
|
}
|
2019-04-10 14:09:32 +00:00
|
|
|
else
|
|
|
|
return Result::Skipped;
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|
2019-05-29 20:26:18 +00:00
|
|
|
catch (boost::exception const& _e)
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, RED}) <<
|
2019-02-06 11:10:48 +00:00
|
|
|
"Exception during test: " << boost::diagnostic_information(_e) << endl;
|
2018-04-03 10:05:26 +00:00
|
|
|
return Result::Exception;
|
|
|
|
}
|
2018-04-06 16:37:01 +00:00
|
|
|
catch (std::exception const& _e)
|
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, RED}) <<
|
2019-05-29 20:26:18 +00:00
|
|
|
"Exception during test" <<
|
|
|
|
(_e.what() ? ": " + string(_e.what()) : ".") <<
|
|
|
|
endl;
|
2018-04-06 16:37:01 +00:00
|
|
|
return Result::Exception;
|
|
|
|
}
|
2018-05-17 12:57:21 +00:00
|
|
|
catch (...)
|
2018-04-03 10:05:26 +00:00
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, RED}) <<
|
2019-02-06 11:10:48 +00:00
|
|
|
"Unknown exception during test." << endl;
|
2018-04-03 10:05:26 +00:00
|
|
|
return Result::Exception;
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 13:08:56 +00:00
|
|
|
TestTool::Request TestTool::handleResponse(bool _exception)
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2018-04-03 10:05:26 +00:00
|
|
|
if (_exception)
|
2018-03-14 18:15:48 +00:00
|
|
|
cout << "(e)dit/(s)kip/(q)uit? ";
|
|
|
|
else
|
|
|
|
cout << "(e)dit/(u)pdate expectations/(s)kip/(q)uit? ";
|
|
|
|
cout.flush();
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
switch(readStandardInputChar())
|
|
|
|
{
|
|
|
|
case 's':
|
|
|
|
cout << endl;
|
|
|
|
return Request::Skip;
|
|
|
|
case 'u':
|
2018-04-03 10:05:26 +00:00
|
|
|
if (_exception)
|
2018-03-14 18:15:48 +00:00
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cout << endl;
|
|
|
|
ofstream file(m_path.string(), ios::trunc);
|
2018-06-08 12:17:50 +00:00
|
|
|
m_test->printSource(file);
|
2020-03-19 01:48:42 +00:00
|
|
|
m_test->printSettings(file);
|
2018-03-14 18:15:48 +00:00
|
|
|
file << "// ----" << endl;
|
2018-06-08 12:17:50 +00:00
|
|
|
m_test->printUpdatedExpectations(file, "// ");
|
2018-03-14 18:15:48 +00:00
|
|
|
return Request::Rerun;
|
|
|
|
}
|
|
|
|
case 'e':
|
|
|
|
cout << endl << endl;
|
2018-06-08 12:17:50 +00:00
|
|
|
if (system((TestTool::editor + " \"" + m_path.string() + "\"").c_str()))
|
2018-03-14 18:15:48 +00:00
|
|
|
cerr << "Error running editor command." << endl << endl;
|
|
|
|
return Request::Rerun;
|
|
|
|
case 'q':
|
|
|
|
cout << endl;
|
|
|
|
return Request::Quit;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-08 12:17:50 +00:00
|
|
|
TestStats TestTool::processPath(
|
2019-04-10 21:00:47 +00:00
|
|
|
TestCreator _testCaseCreator,
|
|
|
|
TestOptions const& _options,
|
2018-03-14 18:15:48 +00:00
|
|
|
fs::path const& _basepath,
|
2019-04-10 21:00:47 +00:00
|
|
|
fs::path const& _path
|
2018-03-14 18:15:48 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
std::queue<fs::path> paths;
|
|
|
|
paths.push(_path);
|
|
|
|
int successCount = 0;
|
2018-08-07 17:28:21 +00:00
|
|
|
int testCount = 0;
|
2019-03-15 16:22:04 +00:00
|
|
|
int skippedCount = 0;
|
2018-03-14 18:15:48 +00:00
|
|
|
|
|
|
|
while (!paths.empty())
|
|
|
|
{
|
|
|
|
auto currentPath = paths.front();
|
|
|
|
|
|
|
|
fs::path fullpath = _basepath / currentPath;
|
|
|
|
if (fs::is_directory(fullpath))
|
|
|
|
{
|
|
|
|
paths.pop();
|
|
|
|
for (auto const& entry: boost::iterator_range<fs::directory_iterator>(
|
|
|
|
fs::directory_iterator(fullpath),
|
|
|
|
fs::directory_iterator()
|
|
|
|
))
|
2018-06-08 12:17:50 +00:00
|
|
|
if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
|
2018-03-16 10:40:03 +00:00
|
|
|
paths.push(currentPath / entry.path().filename());
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|
2018-08-07 17:28:21 +00:00
|
|
|
else if (m_exitRequested)
|
|
|
|
{
|
|
|
|
++testCount;
|
|
|
|
paths.pop();
|
|
|
|
}
|
2018-03-14 18:15:48 +00:00
|
|
|
else
|
|
|
|
{
|
2018-08-07 17:28:21 +00:00
|
|
|
++testCount;
|
2019-04-10 14:09:32 +00:00
|
|
|
TestTool testTool(
|
|
|
|
_testCaseCreator,
|
2019-04-10 21:00:47 +00:00
|
|
|
_options,
|
2019-04-10 14:09:32 +00:00
|
|
|
fullpath,
|
2019-09-11 10:51:26 +00:00
|
|
|
currentPath.generic_path().string()
|
2019-04-10 14:09:32 +00:00
|
|
|
);
|
2018-03-14 18:15:48 +00:00
|
|
|
auto result = testTool.process();
|
|
|
|
|
|
|
|
switch(result)
|
|
|
|
{
|
|
|
|
case Result::Failure:
|
2018-04-03 10:05:26 +00:00
|
|
|
case Result::Exception:
|
|
|
|
switch(testTool.handleResponse(result == Result::Exception))
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
|
|
|
case Request::Quit:
|
2018-08-07 17:28:21 +00:00
|
|
|
paths.pop();
|
|
|
|
m_exitRequested = true;
|
|
|
|
break;
|
2018-03-14 18:15:48 +00:00
|
|
|
case Request::Rerun:
|
|
|
|
cout << "Re-running test case..." << endl;
|
2018-08-07 17:28:21 +00:00
|
|
|
--testCount;
|
2018-03-14 18:15:48 +00:00
|
|
|
break;
|
|
|
|
case Request::Skip:
|
|
|
|
paths.pop();
|
2019-03-15 16:22:04 +00:00
|
|
|
++skippedCount;
|
2018-03-14 18:15:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Result::Success:
|
|
|
|
paths.pop();
|
|
|
|
++successCount;
|
|
|
|
break;
|
2019-03-15 16:22:04 +00:00
|
|
|
case Result::Skipped:
|
|
|
|
paths.pop();
|
|
|
|
++skippedCount;
|
|
|
|
break;
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-15 16:22:04 +00:00
|
|
|
return { successCount, testCount, skippedCount };
|
2018-03-14 18:15:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-10-09 13:25:28 +00:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
2018-07-10 08:36:36 +00:00
|
|
|
void setupTerminal()
|
|
|
|
{
|
|
|
|
#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
|
|
// Set output mode to handle virtual terminal (ANSI escape sequences)
|
|
|
|
// ignore any error, as this is just a "nice-to-have"
|
|
|
|
// only windows needs to be taken care of, as other platforms (Linux/OSX) support them natively.
|
|
|
|
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
if (hOut == INVALID_HANDLE_VALUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DWORD dwMode = 0;
|
|
|
|
if (!GetConsoleMode(hOut, &dwMode))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
|
|
|
|
if (!SetConsoleMode(hOut, dwMode))
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-10-28 10:39:30 +00:00
|
|
|
std::optional<TestStats> runTestSuite(
|
2019-04-10 21:00:47 +00:00
|
|
|
TestCreator _testCaseCreator,
|
|
|
|
TestOptions const& _options,
|
2018-10-09 13:36:40 +00:00
|
|
|
fs::path const& _basePath,
|
|
|
|
fs::path const& _subdirectory,
|
2019-04-10 21:00:47 +00:00
|
|
|
string const& _name
|
2018-10-09 13:36:40 +00:00
|
|
|
)
|
|
|
|
{
|
2019-04-10 21:00:47 +00:00
|
|
|
fs::path testPath{_basePath / _subdirectory};
|
|
|
|
bool formatted{!_options.noColor};
|
2018-10-09 13:36:40 +00:00
|
|
|
|
|
|
|
if (!fs::exists(testPath) || !fs::is_directory(testPath))
|
|
|
|
{
|
|
|
|
cerr << _name << " tests not found. Use the --testpath argument." << endl;
|
2019-10-28 10:39:30 +00:00
|
|
|
return std::nullopt;
|
2018-10-09 13:36:40 +00:00
|
|
|
}
|
|
|
|
|
2019-04-10 14:09:32 +00:00
|
|
|
TestStats stats = TestTool::processPath(
|
|
|
|
_testCaseCreator,
|
2019-04-10 21:00:47 +00:00
|
|
|
_options,
|
2019-04-10 14:09:32 +00:00
|
|
|
_basePath,
|
2019-04-10 21:00:47 +00:00
|
|
|
_subdirectory
|
2019-04-10 14:09:32 +00:00
|
|
|
);
|
2018-10-09 13:36:40 +00:00
|
|
|
|
2019-04-10 14:09:32 +00:00
|
|
|
if (stats.skippedCount != stats.testCount)
|
2019-03-15 16:22:04 +00:00
|
|
|
{
|
2019-04-10 14:09:32 +00:00
|
|
|
cout << endl << _name << " Test Summary: ";
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
2019-04-10 14:09:32 +00:00
|
|
|
stats.successCount <<
|
|
|
|
"/" <<
|
|
|
|
stats.testCount;
|
|
|
|
cout << " tests successful";
|
|
|
|
if (stats.skippedCount > 0)
|
|
|
|
{
|
|
|
|
cout << " (";
|
2019-04-10 21:00:47 +00:00
|
|
|
AnsiColorized(cout, formatted, {BOLD, YELLOW}) << stats.skippedCount;
|
2019-04-10 14:09:32 +00:00
|
|
|
cout<< " tests skipped)";
|
|
|
|
}
|
|
|
|
cout << "." << endl << endl;
|
2019-03-15 16:22:04 +00:00
|
|
|
}
|
2018-10-09 13:36:40 +00:00
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
|
2018-10-09 13:25:28 +00:00
|
|
|
}
|
|
|
|
|
2019-02-19 16:34:59 +00:00
|
|
|
int main(int argc, char const *argv[])
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2018-07-10 08:36:36 +00:00
|
|
|
setupTerminal();
|
|
|
|
|
2018-03-14 18:15:48 +00:00
|
|
|
{
|
2020-01-14 16:48:17 +00:00
|
|
|
auto options = std::make_unique<solidity::test::IsolTestOptions>(&TestTool::editor);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!options->parse(argc, argv))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
options->validate();
|
|
|
|
solidity::test::CommonOptions::setSingleton(std::move(options));
|
|
|
|
}
|
|
|
|
catch (std::exception const& _exception)
|
|
|
|
{
|
|
|
|
cerr << _exception.what() << endl;
|
2019-02-19 16:34:59 +00:00
|
|
|
return 1;
|
2020-01-14 16:48:17 +00:00
|
|
|
}
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|
2020-01-14 16:48:17 +00:00
|
|
|
|
|
|
|
auto& options = dynamic_cast<solidity::test::IsolTestOptions const&>(solidity::test::CommonOptions::get());
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2019-12-23 15:50:30 +00:00
|
|
|
bool disableSemantics = !solidity::test::EVMHost::getVM(options.evmonePath.string());
|
2019-07-16 17:05:13 +00:00
|
|
|
if (disableSemantics)
|
|
|
|
{
|
2019-12-23 15:50:30 +00:00
|
|
|
cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using --evmonepath <path>." << endl;
|
2019-07-16 17:05:13 +00:00
|
|
|
cout << "You can download it at" << endl;
|
2019-12-23 15:50:30 +00:00
|
|
|
cout << solidity::test::evmoneDownloadLink << endl;
|
2019-07-16 17:05:13 +00:00
|
|
|
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
|
|
|
|
}
|
|
|
|
|
2018-10-09 13:36:40 +00:00
|
|
|
TestStats global_stats{0, 0};
|
2019-04-10 14:09:32 +00:00
|
|
|
cout << "Running tests..." << endl << endl;
|
2018-03-14 18:15:48 +00:00
|
|
|
|
2018-10-09 13:43:55 +00:00
|
|
|
// Actually run the tests.
|
2018-12-05 17:00:23 +00:00
|
|
|
// Interactive tests are added in InteractiveTests.h
|
|
|
|
for (auto const& ts: g_interactiveTestsuites)
|
2018-10-10 12:31:49 +00:00
|
|
|
{
|
2019-07-17 08:24:23 +00:00
|
|
|
if (ts.needsVM && disableSemantics)
|
2019-02-06 11:10:48 +00:00
|
|
|
continue;
|
|
|
|
|
2019-02-19 16:34:59 +00:00
|
|
|
if (ts.smt && options.disableSMT)
|
2018-12-05 17:00:23 +00:00
|
|
|
continue;
|
2018-11-15 15:47:52 +00:00
|
|
|
|
2019-04-10 14:09:32 +00:00
|
|
|
auto stats = runTestSuite(
|
2019-04-10 21:00:47 +00:00
|
|
|
ts.testCaseCreator,
|
|
|
|
options,
|
2019-04-10 14:09:32 +00:00
|
|
|
options.testPath / ts.path,
|
|
|
|
ts.subpath,
|
2019-04-10 21:00:47 +00:00
|
|
|
ts.title
|
2019-04-10 14:09:32 +00:00
|
|
|
);
|
|
|
|
if (stats)
|
2018-11-15 15:47:52 +00:00
|
|
|
global_stats += *stats;
|
|
|
|
else
|
|
|
|
return 1;
|
2018-10-10 12:31:49 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 17:30:18 +00:00
|
|
|
cout << endl << "Summary: ";
|
2019-02-21 15:42:23 +00:00
|
|
|
AnsiColorized(cout, !options.noColor, {BOLD, global_stats ? GREEN : RED}) <<
|
2018-08-07 17:28:21 +00:00
|
|
|
global_stats.successCount << "/" << global_stats.testCount;
|
2019-03-15 16:22:04 +00:00
|
|
|
cout << " tests successful";
|
|
|
|
if (global_stats.skippedCount > 0)
|
|
|
|
{
|
|
|
|
cout << " (";
|
|
|
|
AnsiColorized(cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount;
|
2019-03-18 13:08:56 +00:00
|
|
|
cout << " tests skipped)";
|
2019-03-15 16:22:04 +00:00
|
|
|
}
|
|
|
|
cout << "." << endl;
|
2018-08-03 17:30:18 +00:00
|
|
|
|
2019-07-16 17:05:13 +00:00
|
|
|
if (disableSemantics)
|
2019-12-23 15:50:30 +00:00
|
|
|
cout << "\nNOTE: Skipped semantics tests because " << solidity::test::evmoneFilename << " could not be found.\n" << endl;
|
2019-07-16 17:05:13 +00:00
|
|
|
|
2018-08-03 17:30:18 +00:00
|
|
|
return global_stats ? 0 : 1;
|
2018-03-14 18:15:48 +00:00
|
|
|
}
|