summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'QA/Checker/checker.cpp')
-rw-r--r--QA/Checker/checker.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp
index bcf0f5c..3cc7713 100644
--- a/QA/Checker/checker.cpp
+++ b/QA/Checker/checker.cpp
@@ -1,42 +1,43 @@
/*
* Copyright (c) 2010-2017 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <cstdlib>
#include <fstream>
#include <string>
#include <sstream>
#include <gtest/gtest.h>
+#include <QA/Checker/CppUnitTestResultPrinter.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/TextOutputter.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/TextTestResult.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <Swiften/Base/Log.h>
using Swift::Log;
int main(int argc, char* argv[]) {
bool verbose = false;
bool outputXML = false;
Log::setLogLevel(Swift::Log::error);
// Parse parameters
std::vector<std::string> testsToRun;
for (int i = 1; i < argc; ++i) {
std::string param(argv[i]);
if (param == "--verbose") {
verbose = true;
}
else if (param == "--xml") {
outputXML = true;
}
else if (param == "--debug") {
@@ -99,40 +100,46 @@ int main(int argc, char* argv[]) {
for (std::vector<std::string>::const_iterator i = testsToRun.begin(); i != testsToRun.end(); ++i) {
try {
runner.run(controller, *i);
}
catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return -1;
}
}
// Output the results
if (outputXML) {
std::ofstream cppUnitXUnitOutputFile;
cppUnitXUnitOutputFile.open(cppunitOutputFilename, std::ofstream::out | std::ofstream::trunc);
if (cppUnitXUnitOutputFile.is_open()) {
CppUnit::XmlOutputter outputter(&result, cppUnitXUnitOutputFile);
outputter.write();
}
else {
std::cerr << "Failed to overwrite " << cppunitOutputFilename << " output file." << std::endl;
return 1;
}
}
else {
CppUnit::TextOutputter outputter(&result, std::cerr);
outputter.write();
}
auto googleTestWasSuccessful = false;
try {
+ if (!verbose) {
+ testing::UnitTest& unitTest = *testing::UnitTest::GetInstance();
+ testing::TestEventListeners& listeners = unitTest.listeners();
+ delete listeners.Release(listeners.default_result_printer());
+ listeners.Append(new testing::CppUnitTestResultPrinter);
+ }
googleTestWasSuccessful = RUN_ALL_TESTS() == 0 ? true : false;
} catch (const ::testing::internal::GoogleTestFailureException& e) {
googleTestWasSuccessful = false;
SWIFT_LOG(error) << "GoogleTestFailureException was thrown: " << e.what() << std::endl;
}
auto cppUnitWasSuccessful = result.wasSuccessful() ? true : false;
return (googleTestWasSuccessful && cppUnitWasSuccessful) ? 0 : 1;
}