better console printing

This commit is contained in:
John Bintz 2011-05-13 09:15:49 -04:00
parent 756f3d498e
commit 4fdfd7b84b

View File

@ -87,6 +87,7 @@ private:
bool showColors; bool showColors;
bool isFinished; bool isFinished;
bool didFail; bool didFail;
bool consoleNotUsedThisRun;
void red(); void red();
void green(); void green();
@ -102,6 +103,7 @@ HeadlessSpecRunner::HeadlessSpecRunner()
, showColors(false) , showColors(false)
, isFinished(false) , isFinished(false)
, didFail(false) , didFail(false)
, consoleNotUsedThisRun(false)
{ {
m_page.settings()->enablePersistentStorage(); m_page.settings()->enablePersistentStorage();
connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(watch(bool))); connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(watch(bool)));
@ -162,6 +164,7 @@ void HeadlessSpecRunner::clear()
void HeadlessSpecRunner::specPassed() void HeadlessSpecRunner::specPassed()
{ {
consoleNotUsedThisRun = true;
green(); green();
std::cout << '.'; std::cout << '.';
clear(); clear();
@ -170,6 +173,7 @@ void HeadlessSpecRunner::specPassed()
void HeadlessSpecRunner::specFailed() void HeadlessSpecRunner::specFailed()
{ {
consoleNotUsedThisRun = true;
didFail = true; didFail = true;
red(); red();
std::cout << 'F'; std::cout << 'F';
@ -202,6 +206,10 @@ void HeadlessSpecRunner::log(const QString &msg)
{ {
usedConsole = true; usedConsole = true;
green(); green();
if (consoleNotUsedThisRun) {
std::cout << std::endl;
consoleNotUsedThisRun = false;
}
std::cout << "[console] "; std::cout << "[console] ";
clear(); clear();
std::cout << qPrintable(msg); std::cout << qPrintable(msg);