have runner define report files as a queue

This commit is contained in:
John Bintz 2011-12-12 14:54:53 -05:00
parent e03389e938
commit 5743227de6
2 changed files with 17 additions and 13 deletions

View File

@ -62,14 +62,10 @@ void Runner::handleError(const QString &message, int lineNumber, const QString &
void Runner::loadSpec() void Runner::loadSpec()
{ {
if (reportFileName.isEmpty()) { if (!reportFileName.isEmpty()) {
outputFile = 0; QFile *outputFile = new QFile(reportFileName);
ts = 0;
} else {
outputFile = new QFile(reportFileName);
outputFile->open(QIODevice::WriteOnly); outputFile->open(QIODevice::WriteOnly);
outputFiles.enqueue(outputFile);
ts = new QTextStream(outputFile);
} }
page.mainFrame()->load(runnerFiles.dequeue()); page.mainFrame()->load(runnerFiles.dequeue());
@ -131,9 +127,14 @@ void Runner::print(const QString &fh, const QString &content) {
std::cerr.flush(); std::cerr.flush();
} }
if (fh == "report" && outputFile) { if (fh == "report") {
*ts << qPrintable(content); QListIterator<QFile *> iterator(outputFiles);
ts->flush();
while (iterator.hasNext()) {
QTextStream ts(iterator.next());
ts << qPrintable(content);
ts.flush();
}
} }
} }
@ -149,8 +150,10 @@ void Runner::timerEvent() {
QApplication::instance()->exit(1); QApplication::instance()->exit(1);
if (isFinished && runs > 2) { if (isFinished && runs > 2) {
if (outputFile) { QListIterator<QFile *> iterator(outputFiles);
outputFile->close();
while (iterator.hasNext()) {
iterator.next()->close();
} }
int exitCode = 0; int exitCode = 0;

View File

@ -56,8 +56,9 @@ class Runner: public QObject {
void loadSpec(); void loadSpec();
QQueue<QFile *> outputFiles;
QFile *outputFile; QFile *outputFile;
QTextStream *ts;
}; };
#endif #endif