Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorRobert Dailey2016-04-01 11:54:23 -0500
committerRobert Dailey2016-04-01 11:56:51 -0500
commit86c0ea2999d1b64af2d1771687567bc4bed2d3f9 (patch)
treef7ace2d105d0d64347464207aaeea69a055784dd /include
parentc984fc3ecde60b59efa2203e82261acac8ac8502 (diff)
downloadcatch3-86c0ea2999d1b64af2d1771687567bc4bed2d3f9.tar.gz
[#608] Don't use exit() on duplicate test descriptions
Instead of `exit(1)`, it now throws `std::runtime_error` with the details of the failure. This exception is handled in `run()` at a higher level where the log is printed to cerr and the test gracefully exits.
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_test_case_registry_impl.hpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/include/internal/catch_test_case_registry_impl.hpp b/include/internal/catch_test_case_registry_impl.hpp
index a2b041a3..cc48d917 100644
--- a/include/internal/catch_test_case_registry_impl.hpp
+++ b/include/internal/catch_test_case_registry_impl.hpp
@@ -60,13 +60,15 @@ namespace Catch {
it != itEnd;
++it ) {
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
- if( !prev.second ){
- Catch::cerr()
- << Colour( Colour::Red )
- << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
- << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
- << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
- exit(1);
+ if( !prev.second ) {
+ std::ostringstream ss;
+
+ ss << Colour( Colour::Red )
+ << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
+ << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
+ << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
+
+ throw std::runtime_error(ss.str());
}
}
}