diff --git a/test/Common.cpp b/test/Common.cpp
new file mode 100644
index 000000000..a80c55d4c
--- /dev/null
+++ b/test/Common.cpp
@@ -0,0 +1,50 @@
+/*
+ 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 .
+*/
+
+#include
+
+#include
+
+namespace fs = boost::filesystem;
+
+namespace dev
+{
+namespace test
+{
+
+boost::filesystem::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 {};
+}
+
+
+}
+}
diff --git a/test/Common.h b/test/Common.h
new file mode 100644
index 000000000..e87faa0e6
--- /dev/null
+++ b/test/Common.h
@@ -0,0 +1,35 @@
+/*
+ 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 .
+*/
+
+#pragma once
+
+#include
+
+namespace dev
+{
+namespace test
+{
+
+/// Tries to find a path that contains the directories "libsolidity/syntaxTests"
+/// and returns it if found.
+/// The routine searches in the current directory, and inside the "test" directory
+/// starting from the current directory and up to three levels up.
+/// @returns the path of the first match or an empty path if not found.
+boost::filesystem::path discoverTestPath();
+
+}
+}
diff --git a/test/Options.cpp b/test/Options.cpp
index 635882378..da08eb37d 100644
--- a/test/Options.cpp
+++ b/test/Options.cpp
@@ -21,6 +21,8 @@
#include
+#include
+
#include
#include
@@ -74,25 +76,7 @@ Options::Options()
testPath = path;
if (testPath.empty())
- {
- 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;
- }
- }
- }
+ testPath = discoverTestPath();
}
void Options::validate() const
diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt
index d6df0ac84..2f107d39c 100644
--- a/test/tools/CMakeLists.txt
+++ b/test/tools/CMakeLists.txt
@@ -1,7 +1,7 @@
add_executable(solfuzzer fuzzer.cpp)
target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_SYSTEM_LIBRARIES})
-add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
+add_executable(isoltest isoltest.cpp ../Options.cpp ../Common.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
../RPCSession.cpp ../libsolidity/ASTJSONTest.cpp)
target_link_libraries(isoltest PRIVATE libsolc solidity evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp
index 5cf1d9c0b..dac87d1c0 100644
--- a/test/tools/isoltest.cpp
+++ b/test/tools/isoltest.cpp
@@ -16,6 +16,8 @@
*/
#include
+
+#include
#include
#include
#include
@@ -47,7 +49,7 @@ struct TestStats
int successCount;
int testCount;
operator bool() const { return successCount == testCount; }
- TestStats& operator+=(TestStats const& _other)
+ TestStats& operator+=(TestStats const& _other) noexcept
{
successCount += _other.successCount;
testCount += _other.testCount;
@@ -285,25 +287,6 @@ void setupTerminal()
#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 {};
-}
-
boost::optional runTestSuite(
string const& _name,
fs::path const& _basePath,
@@ -384,7 +367,7 @@ Allowed options)",
}
if (testPath.empty())
- testPath = discoverTestPath();
+ testPath = dev::test::discoverTestPath();
TestStats global_stats{0, 0};