Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
halfway in the middle of the reporting change
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbintz committed Sep 2, 2011
1 parent 68a2888 commit e5510f1
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 230 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -11,3 +11,4 @@ moc_*.*
.DS_Store
hydra-runner.log
jhw-test
.jhw-cache/
3 changes: 2 additions & 1 deletion Guardfile
Expand Up @@ -26,7 +26,8 @@ guard 'jasmine-headless-webkit', :all_on_start => false do
end

def compile
system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb}
#system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb}
system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
end

compile
Expand Down
44 changes: 44 additions & 0 deletions ext/jasmine-webkit-specrunner/ReportFileOutput.cpp
@@ -1,10 +1,54 @@
#include "ReportFileOutput.h"

using namespace std;

ReportFileOutput::ReportFileOutput() : QObject() {
reset();
}

void ReportFileOutput::reset() {
buffer = new stringstream();

outputIO = buffer;
}

void ReportFileOutput::passed(const QString &specDetail) {
*outputIO << "PASS||" << qPrintable(specDetail) << std::endl;
successes.push(specDetail);
}

void ReportFileOutput::failed(const QString &specDetail) {
*outputIO << "FAIL||" << qPrintable(specDetail) << std::endl;
failures.push(specDetail);
}

void ReportFileOutput::errorLog(const QString &msg, int lineNumber, const QString &sourceID) {
*outputIO << "ERROR||" << qPrintable(msg) << "||" << qPrintable(sourceID) << ":" << lineNumber << std::endl;
}

void ReportFileOutput::consoleLog(const QString &msg) {
*outputIO << "CONSOLE||" << qPrintable(msg) << std::endl;
}

void ReportFileOutput::internalLog(const QString &, const QString &) {}
void ReportFileOutput::logSpecFilename(const QString &) {}
void ReportFileOutput::logSpecResult(const QString &) {}

void ReportFileOutput::reportFailure(const QString &totalTests, const QString &failedTests, const QString &duration) {
reportTotals(totalTests, failedTests, duration, false);
}

void ReportFileOutput::reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration) {
reportTotals(totalTests, failedTests, duration, false);
}

void ReportFileOutput::reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration) {
reportTotals(totalTests, failedTests, duration, true);
}

void ReportFileOutput::reportTotals(const QString &totalTests, const QString &failedTests, const QString &duration, bool hasJavaScriptError) {
*outputIO << "TOTAL||" << qPrintable(totalTests) << "||" << qPrintable(failedTests) << "||" << qPrintable(duration) << "||";
*outputIO << (hasJavaScriptError ? "T" : "F");
*outputIO << std::endl;
}

10 changes: 9 additions & 1 deletion ext/jasmine-webkit-specrunner/ReportFileOutput.h
Expand Up @@ -4,6 +4,9 @@
#include <QObject>
#include <iostream>
#include <QStack>
#include <sstream>

using namespace std;

class ReportFileOutput : public QObject {
public:
Expand All @@ -21,9 +24,14 @@ class ReportFileOutput : public QObject {
void reportSuccess(const QString &totalTests, const QString &failedTests, const QString &duration);
void reportSuccessWithJSErrors(const QString &totalTests, const QString &failedTests, const QString &duration);

std::ostream *outputIO;
void reset();

stringstream *buffer;
stringstream *outputIO;
QStack<QString> successes;
QStack<QString> failures;
private:
void reportTotals(const QString &totalTests, const QString &failedTests, const QString &duration, bool hasJavaScriptError);
};

#endif
57 changes: 56 additions & 1 deletion ext/jasmine-webkit-specrunner/ReportFileOutput_test.cpp
Expand Up @@ -23,11 +23,66 @@ void ReportFileOutputTest::testFailed() {
ReportFileOutput output;

output.outputIO = &buffer;
output.passed("test||done||file.js:23");
output.failed("test||done||file.js:23");
QVERIFY(buffer.str() == "FAIL||test||done||file.js:23\n");
QVERIFY(output.successes.size() == 0);
QVERIFY(output.failures.size() == 1);
}

void ReportFileOutputTest::testErrorLog() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.errorLog("JS Error", 23, "file.js");
QVERIFY(buffer.str() == "ERROR||JS Error||file.js:23\n");
}

void ReportFileOutputTest::testConsoleLog() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.consoleLog("Console");
QVERIFY(buffer.str() == "CONSOLE||Console\n");
}

void ReportFileOutputTest::testStubMethods() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.internalLog("Internal", "Log");
output.logSpecFilename("Filename");
output.logSpecResult("REsult");
}

void ReportFileOutputTest::testReportFailure() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.reportFailure("5", "2", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||2||1.5||F\n");
}

void ReportFileOutputTest::testReportSuccess() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.reportSuccess("5", "0", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||F\n");
}

void ReportFileOutputTest::testReportSuccessWithJSErrors() {
stringstream buffer;
ReportFileOutput output;

output.outputIO = &buffer;
output.reportSuccessWithJSErrors("5", "0", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||T\n");
}

QTEST_MAIN(ReportFileOutputTest);

6 changes: 6 additions & 0 deletions ext/jasmine-webkit-specrunner/ReportFileOutput_test.h
Expand Up @@ -15,6 +15,12 @@ class ReportFileOutputTest : public QObject {
private slots:
void testPassed();
void testFailed();
void testErrorLog();
void testConsoleLog();
void testStubMethods();
void testReportFailure();
void testReportSuccess();
void testReportSuccessWithJSErrors();
};

#endif

0 comments on commit e5510f1

Please sign in to comment.