Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions test/fixture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
Expand Down
22 changes: 0 additions & 22 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,13 @@

#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
#if defined(_MSC_VER) && defined(_DEBUG)
_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);
Expand All @@ -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
}