mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
boostTest: Give BOOST_REQUIRE_NO_THROW a smaller block of code to make the error message clearer when a test raises an unexpected exception
This commit is contained in:
parent
cbf1c3ae69
commit
030fb1d9a2
@ -60,6 +60,31 @@ void removeTestSuite(std::string const& _name)
|
||||
master.remove(id);
|
||||
}
|
||||
|
||||
void runTestCase(TestCase::Config const& _config, TestCase::TestCaseCreator const& _testCaseCreator)
|
||||
{
|
||||
try
|
||||
{
|
||||
stringstream errorStream;
|
||||
auto testCase = _testCaseCreator(_config);
|
||||
if (testCase->shouldRun())
|
||||
switch (testCase->run(errorStream))
|
||||
{
|
||||
case TestCase::TestResult::Success:
|
||||
break;
|
||||
case TestCase::TestResult::Failure:
|
||||
BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
|
||||
break;
|
||||
case TestCase::TestResult::FatalError:
|
||||
BOOST_ERROR("Fatal error during test.\n" + errorStream.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (boost::exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Exception during extracted test: " << boost::diagnostic_information(_e));
|
||||
}
|
||||
}
|
||||
|
||||
int registerTests(
|
||||
boost::unit_test::test_suite& _suite,
|
||||
boost::filesystem::path const& _basepath,
|
||||
@ -114,27 +139,7 @@ int registerTests(
|
||||
[config, _testCaseCreator]
|
||||
{
|
||||
BOOST_REQUIRE_NO_THROW({
|
||||
try
|
||||
{
|
||||
stringstream errorStream;
|
||||
auto testCase = _testCaseCreator(config);
|
||||
if (testCase->shouldRun())
|
||||
switch (testCase->run(errorStream))
|
||||
{
|
||||
case TestCase::TestResult::Success:
|
||||
break;
|
||||
case TestCase::TestResult::Failure:
|
||||
BOOST_ERROR("Test expectation mismatch.\n" + errorStream.str());
|
||||
break;
|
||||
case TestCase::TestResult::FatalError:
|
||||
BOOST_ERROR("Fatal error during test.\n" + errorStream.str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (boost::exception const& _e)
|
||||
{
|
||||
BOOST_ERROR("Exception during extracted test: " << boost::diagnostic_information(_e));
|
||||
}
|
||||
runTestCase(config, _testCaseCreator);
|
||||
});
|
||||
},
|
||||
_path.stem().string(),
|
||||
|
Loading…
Reference in New Issue
Block a user