aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/main.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-09-16 15:45:38 -0400
committerJack Lloyd <[email protected]>2016-09-16 15:45:38 -0400
commit4266b51c35d7c0e86f513030ae4a5b28fdb9b824 (patch)
treebb4ceeaf9190a5dbadbc66f0dc4a3f6274cffae0 /src/tests/main.cpp
parent45a8210d63c2fc0b0ab0411dba55c903da226123 (diff)
Add try/catch block at top-level test runner
Diffstat (limited to 'src/tests/main.cpp')
-rw-r--r--src/tests/main.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/tests/main.cpp b/src/tests/main.cpp
index 07aaac519..b771d9614 100644
--- a/src/tests/main.cpp
+++ b/src/tests/main.cpp
@@ -228,8 +228,14 @@ class Test_Runner : public Botan_CLI::Command
{
for(auto&& test_name : tests_to_run)
{
- const auto results = Botan_Tests::Test::run_test(test_name, false);
- out << report_out(results, tests_failed, tests_ran) << std::flush;
+ try {
+ const auto results = Botan_Tests::Test::run_test(test_name, false);
+ out << report_out(results, tests_failed, tests_ran) << std::flush;
+ }
+ catch(std::exception& e)
+ {
+ out << "Test " << test_name << " failed with exception " << e.what() << std::flush;
+ }
}
}
else
@@ -250,7 +256,15 @@ class Test_Runner : public Botan_CLI::Command
for(auto&& test_name : tests_to_run)
{
auto run_it = [test_name] {
- return Botan_Tests::Test::run_test(test_name, false);
+ try {
+ return Botan_Tests::Test::run_test(test_name, false);
+ }
+ catch(std::exception& e)
+ {
+ Botan_Tests::Test::Result r(test_name);
+ r.test_failure("Exception thrown", e.what());
+ return std::vector<Botan_Tests::Test::Result>{r};
+ }
};
fut_results.push_back(std::async(std::launch::async, run_it));