Only consider files ending with .sol and not starting with ~ in syntax tests.

This commit is contained in:
Daniel Kirchner 2018-03-16 11:40:03 +01:00
parent 9e1095608d
commit e68c19c47b
3 changed files with 13 additions and 2 deletions

View File

@ -205,6 +205,13 @@ test_case *make_test_case(
} }
#endif #endif
bool SyntaxTest::isTestFilename(boost::filesystem::path const& _filename)
{
return _filename.extension().string() == ".sol" &&
!boost::starts_with(_filename.string(), "~") &&
!boost::starts_with(_filename.string(), ".");
}
int SyntaxTest::registerTests( int SyntaxTest::registerTests(
boost::unit_test::test_suite& _suite, boost::unit_test::test_suite& _suite,
boost::filesystem::path const& _basepath, boost::filesystem::path const& _basepath,
@ -220,6 +227,7 @@ int SyntaxTest::registerTests(
fs::directory_iterator(fullpath), fs::directory_iterator(fullpath),
fs::directory_iterator() fs::directory_iterator()
)) ))
if (fs::is_directory(entry.path()) || isTestFilename(entry.path().filename()))
numTestsAdded += registerTests(*sub_suite, _basepath, _path / entry.path().filename()); numTestsAdded += registerTests(*sub_suite, _basepath, _path / entry.path().filename());
_suite.add(sub_suite); _suite.add(sub_suite);
} }

View File

@ -71,6 +71,7 @@ public:
boost::filesystem::path const& _basepath, boost::filesystem::path const& _basepath,
boost::filesystem::path const& _path boost::filesystem::path const& _path
); );
static bool isTestFilename(boost::filesystem::path const& _filename);
private: private:
bool matchesExpectations(ErrorList const& _errors) const; bool matchesExpectations(ErrorList const& _errors) const;
static std::string errorMessage(Error const& _e); static std::string errorMessage(Error const& _e);

View File

@ -19,6 +19,7 @@
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/SyntaxTest.h> #include <test/libsolidity/SyntaxTest.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
@ -218,6 +219,7 @@ SyntaxTestStats SyntaxTestTool::processPath(
fs::directory_iterator(fullpath), fs::directory_iterator(fullpath),
fs::directory_iterator() fs::directory_iterator()
)) ))
if (fs::is_directory(entry.path()) || SyntaxTest::isTestFilename(entry.path().filename()))
paths.push(currentPath / entry.path().filename()); paths.push(currentPath / entry.path().filename());
} }
else else