@@ -213,51 +213,78 @@ string const c_copierPostf = "Copier";
213213
214214void TestSuite::runTestWithoutFiller (boost::filesystem::path const & _file) const
215215{
216- for ( auto const & config : Options::getDynamicOptions (). getClientConfigs ())
216+ try
217217 {
218- Options::getDynamicOptions ().setCurrentConfig (config);
219-
220- std::cout << " Running tests for config '" << config.cfgFile ().name () << " ' "
221- << config.getId ().id () << std::endl;
222- ETH_LOG (" Running " + _file.filename ().string () + " : " , 3 );
223-
224- // Allow to execute a custom test .json file on any test suite
225- auto & testOutput = test::TestOutputHelper::get ();
226- testOutput.initTest (1 );
227-
228- if (Options::get ().filltests )
218+ for (auto const & config : Options::getDynamicOptions ().getClientConfigs ())
229219 {
230- TestFileData testData = readTestFile (_file);
231- removeComments (testData.data );
220+ Options::getDynamicOptions ().setCurrentConfig (config);
232221
233- string fileName = _file.stem ().c_str ();
234- if (fileName.find (" Filler" ) == string::npos)
235- ETH_ERROR_MESSAGE (" Trying to fill `" + string (_file.c_str ()) + " `, but file does not have Filler suffix!" );
222+ std::cout << " Running tests for config '" << config.cfgFile ().name () << " ' " << config.getId ().id () << std::endl;
223+ ETH_LOG (" Running " + _file.filename ().string () + " : " , 3 );
236224
237- // output filename. substract Filler suffix
238- fileName = fileName.substr (0 , fileName.length () - 6 ) + " .json" ;
225+ // Allow to execute a custom test .json file on any test suite
226+ auto & testOutput = test::TestOutputHelper::get ();
227+ testOutput.initTest (1 );
239228
240- fs::path outPath;
241- if (Options::get ().singleTestOutFile .is_initialized ())
242- outPath = fs::path (Options::get ().singleTestOutFile .get ());
243- else
244- outPath = _file.parent_path () / fileName;
245-
246- TestSuiteOptions opt;
247- opt.doFilling = true ;
248- opt.allowInvalidBlocks = true ;
249- DataObject output = doTests (testData.data , opt);
250- addClientInfo (output, _file, testData.hash );
251- writeFile (outPath, asBytes (output.asJson ()));
252- }
253- else
254- executeFile (_file);
255-
256- testOutput.finishTest ();
229+ try
230+ {
231+ if (Options::get ().filltests )
232+ {
233+ TestFileData testData = readTestFile (_file);
234+ removeComments (testData.data );
235+
236+ string fileName = _file.stem ().c_str ();
237+ if (fileName.find (" Filler" ) == string::npos)
238+ ETH_ERROR_MESSAGE (
239+ " Trying to fill `" + string (_file.c_str ()) + " `, but file does not have Filler suffix!" );
240+
241+ // output filename. substract Filler suffix
242+ fileName = fileName.substr (0 , fileName.length () - 6 ) + " .json" ;
243+
244+ fs::path outPath;
245+ if (Options::get ().singleTestOutFile .is_initialized ())
246+ outPath = fs::path (Options::get ().singleTestOutFile .get ());
247+ else
248+ outPath = _file.parent_path () / fileName;
249+
250+ TestSuiteOptions opt;
251+ opt.doFilling = true ;
252+ opt.allowInvalidBlocks = true ;
253+ DataObject output = doTests (testData.data , opt);
254+ addClientInfo (output, _file, testData.hash );
255+ writeFile (outPath, asBytes (output.asJson ()));
256+ }
257+ else
258+ executeFile (_file);
259+ }
260+ catch (test::EthError const & _ex)
261+ {
262+ // Something went wrong inside the test. skip the test.
263+ // (error message is stored at TestOutputHelper. EthError is via ETH_ERROR_())
264+ }
265+ catch (test::UpwardsException const & _ex)
266+ {
267+ // UpwardsException is thrown upwards in tests for debug info
268+ // And it should be catched on upper level for report till this point
269+ ETH_ERROR_MESSAGE (string (" Unhandled UpwardsException: " ) + _ex.what ());
270+ }
271+ catch (std::exception const & _ex)
272+ {
273+ if (!ExitHandler::receivedExitSignal ())
274+ ETH_ERROR_MESSAGE (" ERROR OCCURED TESTFILE RUN: " + string (_ex.what ()));
275+ RPCSession::sessionEnd (TestOutputHelper::getThreadID (), RPCSession::SessionStatus::HasFinished);
276+ }
257277
258- // Disconnect threads from the client
259- if (Options::getDynamicOptions ().getClientConfigs ().size () > 1 )
260- RPCSession::clear ();
278+ testOutput.finishTest ();
279+ // Disconnect threads from the client
280+ if (Options::getDynamicOptions ().getClientConfigs ().size () > 1 )
281+ RPCSession::clear ();
282+ }
283+ }
284+ catch (std::exception const &)
285+ {
286+ test::TestOutputHelper::get ().finishTest ();
287+ test::TestOutputHelper::printTestExecStats ();
261288 }
262289}
263290
@@ -479,6 +506,8 @@ void TestSuite::runFunctionForAllClients(std::function<void()> _func)
479506 Options::getDynamicOptions ().setCurrentConfig (config);
480507 std::cout << " Running tests for config '" << config.cfgFile ().name () << " ' "
481508 << config.getId ().id () << std::endl;
509+
510+ // Run tests
482511 _func ();
483512
484513 // Disconnect threads from the client
0 commit comments