2011-08-03 16:26:39 +00:00
|
|
|
#include "ConsoleOutput.h"
|
|
|
|
|
|
|
|
namespace HeadlessSpecRunner {
|
|
|
|
ConsoleOutput::ConsoleOutput() : QObject(),
|
2011-08-29 17:35:36 +00:00
|
|
|
showColors(false),
|
|
|
|
consoleLogUsed(false) {
|
2011-08-03 16:26:39 +00:00
|
|
|
outputIO = &std::cout;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::passed(const QString &specDetail) {
|
|
|
|
green();
|
|
|
|
*outputIO << '.';
|
|
|
|
clear();
|
2011-08-27 14:53:29 +00:00
|
|
|
outputIO->flush();
|
2011-08-03 16:26:39 +00:00
|
|
|
|
2011-08-29 17:35:36 +00:00
|
|
|
consoleLogUsed = false;
|
2011-08-03 16:26:39 +00:00
|
|
|
successes.push(specDetail);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::failed(const QString &specDetail)
|
|
|
|
{
|
|
|
|
red();
|
|
|
|
*outputIO << 'F';
|
|
|
|
clear();
|
2011-08-27 14:53:29 +00:00
|
|
|
outputIO->flush();
|
2011-08-03 16:26:39 +00:00
|
|
|
|
2011-08-29 17:35:36 +00:00
|
|
|
consoleLogUsed = false;
|
2011-08-03 16:26:39 +00:00
|
|
|
failures.push(specDetail);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::green() {
|
|
|
|
if (showColors) std::cout << "\033[0;32m";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::clear() {
|
|
|
|
if (showColors) std::cout << "\033[m";
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::red() {
|
|
|
|
if (showColors) std::cout << "\033[0;31m";
|
|
|
|
}
|
2011-08-26 15:18:04 +00:00
|
|
|
|
|
|
|
void ConsoleOutput::errorLog(const QString &msg, int lineNumber, const QString &sourceID) {
|
|
|
|
red();
|
|
|
|
*outputIO << "[error] ";
|
|
|
|
clear();
|
|
|
|
*outputIO << qPrintable(sourceID) << ":" << lineNumber << " : " << qPrintable(msg);
|
|
|
|
*outputIO << std::endl;
|
|
|
|
}
|
2011-08-29 17:35:36 +00:00
|
|
|
|
|
|
|
void ConsoleOutput::internalLog(const QString ¬e, const QString &msg) {
|
|
|
|
red();
|
|
|
|
*outputIO << "[" << qPrintable(note) << "] ";
|
|
|
|
clear();
|
|
|
|
*outputIO << qPrintable(msg);
|
|
|
|
*outputIO << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::consoleLog(const QString &msg) {
|
|
|
|
if (!consoleLogUsed) {
|
|
|
|
*outputIO << std::endl;
|
|
|
|
consoleLogUsed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
green();
|
|
|
|
*outputIO << "[console] ";
|
|
|
|
if (msg.contains("\n"))
|
|
|
|
*outputIO << std::endl;
|
|
|
|
clear();
|
|
|
|
*outputIO << qPrintable(msg);
|
|
|
|
*outputIO << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConsoleOutput::logSpecFilename(const QString &name) {
|
|
|
|
*outputIO << std::endl << std::endl;
|
|
|
|
red();
|
|
|
|
*outputIO << qPrintable(name) << std::endl;
|
|
|
|
clear();
|
|
|
|
}
|
2011-08-03 16:26:39 +00:00
|
|
|
}
|
2011-08-29 17:35:36 +00:00
|
|
|
|