Skip to content

Commit

Permalink
write test output to a temp file to store it (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
lene committed Apr 16, 2014
1 parent 8f5162f commit f0ec467
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tests/Auxiliary/TestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <typeinfo>
#include <algorithm>
#include <memory>
#include <qt5/QtCore/qobject.h>
#include <iostream>

#include <QObject>

struct TestRunner::Impl {

Expand All @@ -14,6 +16,7 @@ struct TestRunner::Impl {

static void printFailedTestSuite(std::string suite);

static QString getTestOutputFile(const QObject *test);

unsigned executedTestSuites_;
std::vector<QObject *> tests_to_run_;
Expand All @@ -39,12 +42,22 @@ void TestRunner::add(QObject *test) {
}

void TestRunner::run() {
QStringList args;
args.append("-o /tmp/out");
// args.append("");
for (QObject *test: pImpl->tests_to_run_) {
if (QTest::qExec(test, QStringList(args))) pImpl->failedTestSuites_.push_back(typeid(*test).name());
QStringList args;
args << " " << "-o" << TestRunner::Impl::getTestOutputFile(test);
if (QTest::qExec(test, args)) pImpl->failedTestSuites_.push_back(typeid(*test).name());
pImpl->executedTestSuites_++;

QFile file(TestRunner::Impl::getTestOutputFile(test));
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;

QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
std::cerr << line.toStdString() << std::endl;
}

}
pImpl->has_run_ = true;
}
Expand All @@ -69,3 +82,9 @@ void TestRunner::Impl::printFailedTestSuites() const {
void TestRunner::Impl::printFailedTestSuite(std::string suite) {
qDebug() << " " << suite.c_str();
}

QString TestRunner::Impl::getTestOutputFile(const QObject* test) {

QString testname = typeid(*test).name();
return "/tmp/"+testname+".out";
}

0 comments on commit f0ec467

Please sign in to comment.