From 5743227de6445435ec33b503cf4e2dfec4ab9418 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 12 Dec 2011 14:54:53 -0500 Subject: [PATCH] have runner define report files as a queue --- ext/jasmine-webkit-specrunner/Runner.cpp | 27 +++++++++++++----------- ext/jasmine-webkit-specrunner/Runner.h | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ext/jasmine-webkit-specrunner/Runner.cpp b/ext/jasmine-webkit-specrunner/Runner.cpp index 641edf9..3ea407a 100644 --- a/ext/jasmine-webkit-specrunner/Runner.cpp +++ b/ext/jasmine-webkit-specrunner/Runner.cpp @@ -62,14 +62,10 @@ void Runner::handleError(const QString &message, int lineNumber, const QString & void Runner::loadSpec() { - if (reportFileName.isEmpty()) { - outputFile = 0; - ts = 0; - } else { - outputFile = new QFile(reportFileName); + if (!reportFileName.isEmpty()) { + QFile *outputFile = new QFile(reportFileName); outputFile->open(QIODevice::WriteOnly); - - ts = new QTextStream(outputFile); + outputFiles.enqueue(outputFile); } page.mainFrame()->load(runnerFiles.dequeue()); @@ -131,9 +127,14 @@ void Runner::print(const QString &fh, const QString &content) { std::cerr.flush(); } - if (fh == "report" && outputFile) { - *ts << qPrintable(content); - ts->flush(); + if (fh == "report") { + QListIterator iterator(outputFiles); + + while (iterator.hasNext()) { + QTextStream ts(iterator.next()); + ts << qPrintable(content); + ts.flush(); + } } } @@ -149,8 +150,10 @@ void Runner::timerEvent() { QApplication::instance()->exit(1); if (isFinished && runs > 2) { - if (outputFile) { - outputFile->close(); + QListIterator iterator(outputFiles); + + while (iterator.hasNext()) { + iterator.next()->close(); } int exitCode = 0; diff --git a/ext/jasmine-webkit-specrunner/Runner.h b/ext/jasmine-webkit-specrunner/Runner.h index 03e2c53..f49d5fc 100644 --- a/ext/jasmine-webkit-specrunner/Runner.h +++ b/ext/jasmine-webkit-specrunner/Runner.h @@ -56,8 +56,9 @@ class Runner: public QObject { void loadSpec(); + QQueue outputFiles; + QFile *outputFile; - QTextStream *ts; }; #endif