1818 * Fixture class for boost output when running testeth
1919 */
2020
21- #include < boost/test/unit_test.hpp>
22- #include < boost/io/ios_state.hpp>
2321#include < libethashseal/Ethash.h>
2422#include < libethcore/BasicAuthority.h>
25- #include < test/tools/libtesteth/TestOutputHelper.h>
2623#include < test/tools/libtesteth/Options.h>
24+ #include < test/tools/libtesteth/TestOutputHelper.h>
25+ #include < boost/filesystem.hpp>
26+ #include < boost/io/ios_state.hpp>
27+ #include < boost/test/unit_test.hpp>
2728#include < numeric>
2829
2930using namespace std ;
@@ -84,6 +85,7 @@ void TestOutputHelper::finishTest()
8485
8586void TestOutputHelper::printTestExecStats ()
8687{
88+ checkUnfinishedTestFolders ();
8789 if (Options::get ().exectimelog )
8890 {
8991 boost::io::ios_flags_saver saver (cout);
@@ -100,3 +102,86 @@ void TestOutputHelper::printTestExecStats()
100102 saver.restore ();
101103 }
102104}
105+
106+ // check if a boost path contain no test files
107+ bool pathHasTests (boost::filesystem::path const & _path)
108+ {
109+ using fsIterator = boost::filesystem::directory_iterator;
110+ for (fsIterator it (_path); it != fsIterator (); ++it)
111+ {
112+ // if the extention of a test file
113+ if (boost::filesystem::is_regular_file (it->path ()) &&
114+ (it->path ().extension () == " .json" || it->path ().extension () == " .yml" ))
115+ {
116+ // if the filename ends with Filler/Copier type
117+ std::string const name = it->path ().stem ().filename ().string ();
118+ std::string const suffix =
119+ (name.length () > 7 ) ? name.substr (name.length () - 6 ) : string ();
120+ if (suffix == " Filler" || suffix == " Copier" )
121+ return true ;
122+ }
123+ }
124+ return false ;
125+ }
126+
127+ void TestOutputHelper::checkUnfinishedTestFolders ()
128+ {
129+ // -t SuiteName/caseName parse caseName as filter
130+ // rCurrentTestSuite is empty if run without -t argument
131+ string filter;
132+ size_t pos = Options::get ().rCurrentTestSuite .find (' /' );
133+ if (pos != string::npos)
134+ filter = Options::get ().rCurrentTestSuite .substr (pos + 1 );
135+
136+ if (!filter.empty ())
137+ {
138+ if (m_finishedTestFoldersMap.size () != 1 )
139+ {
140+ std::cerr << " ERROR: Expected a single test to be passed: " << filter << " \n " ;
141+ return ;
142+ }
143+ std::map<boost::filesystem::path, FolderNameSet>::const_iterator it =
144+ m_finishedTestFoldersMap.begin ();
145+ if (!pathHasTests (it->first / filter))
146+ std::cerr << " WARNING: Test folder " << it->first / filter
147+ << " appears to have no tests!"
148+ << " \n " ;
149+ }
150+ else
151+ {
152+ for (auto const & allTestsIt : m_finishedTestFoldersMap)
153+ {
154+ boost::filesystem::path path = allTestsIt.first ;
155+ set<string> allFolders;
156+ using fsIterator = boost::filesystem::directory_iterator;
157+ for (fsIterator it (path); it != fsIterator (); ++it)
158+ {
159+ if (boost::filesystem::is_directory (*it))
160+ {
161+ allFolders.insert (it->path ().filename ().string ());
162+ if (!pathHasTests (it->path ()))
163+ std::cerr << " WARNING: Test folder " << it->path ()
164+ << " appears to have no tests!"
165+ << " \n " ;
166+ }
167+ }
168+
169+ std::vector<string> diff;
170+ FolderNameSet finishedFolders = allTestsIt.second ;
171+ std::set_difference (allFolders.begin (), allFolders.end (), finishedFolders.begin (),
172+ finishedFolders.end (), std::back_inserter (diff));
173+ for (auto const & it : diff)
174+ {
175+ std::cerr << " WARNING: Test folder " << path / it << " appears to be unused!"
176+ << " \n " ;
177+ }
178+ }
179+ }
180+ }
181+
182+ void TestOutputHelper::markTestFolderAsFinished (
183+ boost::filesystem::path const & _suitePath, string const & _folderName)
184+ {
185+ // Mark test folder _folderName as finished for the test suite path _suitePath
186+ m_finishedTestFoldersMap[_suitePath].emplace (_folderName);
187+ }
0 commit comments