testrunner: moved exception handling to `TestFixture::run()` and made it unconditional (#4810)
This commit is contained in:
parent
92b42255da
commit
634881db61
|
@ -19,11 +19,13 @@
|
|||
#include "fixture.h"
|
||||
|
||||
#include "color.h"
|
||||
#include "errortypes.h"
|
||||
#include "options.h"
|
||||
#include "redirect.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
@ -311,12 +313,27 @@ void TestFixture::printHelp()
|
|||
void TestFixture::run(const std::string &str)
|
||||
{
|
||||
testToRun = str;
|
||||
if (quiet_tests) {
|
||||
std::cout << '\n' << classname << ':';
|
||||
REDIRECT;
|
||||
run();
|
||||
} else
|
||||
run();
|
||||
try {
|
||||
if (quiet_tests) {
|
||||
std::cout << '\n' << classname << ':';
|
||||
REDIRECT;
|
||||
run();
|
||||
}
|
||||
else
|
||||
run();
|
||||
}
|
||||
catch (const InternalError& e) {
|
||||
++fails_counter;
|
||||
errmsg << "InternalError: " << e.errorMessage << std::endl;
|
||||
}
|
||||
catch (const std::exception& error) {
|
||||
++fails_counter;
|
||||
errmsg << "exception: " << error.what() << std::endl;
|
||||
}
|
||||
catch (...) {
|
||||
++fails_counter;
|
||||
errmsg << "Unknown exception" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void TestFixture::processOptions(const options& args)
|
||||
|
|
|
@ -22,14 +22,6 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#include "errortypes.h" // for InternalError
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// MS Visual C++ memory leak debug tracing
|
||||
|
@ -37,9 +29,6 @@ int main(int argc, char *argv[])
|
|||
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
try {
|
||||
#endif
|
||||
Preprocessor::macroChar = '$'; // While macroChar is char(1) per default outside test suite, we require it to be a human-readable character here.
|
||||
|
||||
options args(argc, argv);
|
||||
|
@ -50,15 +39,4 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
const std::size_t failedTestsCount = TestFixture::runTests(args);
|
||||
return (failedTestsCount == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
#ifdef NDEBUG
|
||||
}
|
||||
catch (const InternalError& e) {
|
||||
std::cout << e.errorMessage << std::endl;
|
||||
} catch (const std::exception& error) {
|
||||
std::cout << error.what() << std::endl;
|
||||
} catch (...) {
|
||||
std::cout << "Unknown exception" << std::endl;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue