Extract function.

This commit is contained in:
chriseth 2018-10-09 15:25:28 +02:00
parent 51db4f5411
commit 9081f803c7

View File

@ -256,6 +256,9 @@ TestStats TestTool::processPath(
} }
namespace
{
void setupTerminal() void setupTerminal()
{ {
#if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) #if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
@ -276,6 +279,27 @@ void setupTerminal()
#endif #endif
} }
fs::path discoverTestPath()
{
auto const searchPath =
{
fs::current_path() / ".." / ".." / ".." / "test",
fs::current_path() / ".." / ".." / "test",
fs::current_path() / ".." / "test",
fs::current_path() / "test",
fs::current_path()
};
for (auto const& basePath: searchPath)
{
fs::path syntaxTestPath = basePath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
return basePath;
}
return {};
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
setupTerminal(); setupTerminal();
@ -326,25 +350,7 @@ Allowed options)",
} }
if (testPath.empty()) if (testPath.empty())
{ testPath = discoverTestPath();
auto const searchPath =
{
fs::current_path() / ".." / ".." / ".." / "test",
fs::current_path() / ".." / ".." / "test",
fs::current_path() / ".." / "test",
fs::current_path() / "test",
fs::current_path()
};
for (auto const& basePath : searchPath)
{
fs::path syntaxTestPath = basePath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
testPath = basePath;
break;
}
}
}
TestStats global_stats { 0, 0 }; TestStats global_stats { 0, 0 };