jasmine-headless-webkit 0.7.3.1 → 0.7.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Guardfile +3 -2
- data/bin/jasmine-headless-webkit +1 -1
- data/ext/jasmine-webkit-specrunner/Page.cpp +8 -21
- data/ext/jasmine-webkit-specrunner/Page.h +11 -15
- data/ext/jasmine-webkit-specrunner/Runner.cpp +86 -110
- data/ext/jasmine-webkit-specrunner/Runner.h +23 -26
- data/ext/jasmine-webkit-specrunner/common.pri +2 -2
- data/ext/jasmine-webkit-specrunner/specrunner.cpp +0 -1
- data/ext/jasmine-webkit-specrunner/specrunner.pro +1 -0
- data/lib/jasmine/files_list.rb +24 -24
- data/lib/jasmine/headless.rb +1 -1
- data/lib/jasmine/headless/spec_file_analyzer.rb +1 -1
- data/lib/jasmine/headless/version.rb +1 -1
- data/lib/qt/qmake.rb +1 -5
- data/skel/template.html.erb +8 -45
- data/spec/files/UTF-8-test.txt +0 -0
- data/spec/javascripts/headless_reporter_result_spec.coffee +14 -0
- data/spec/javascripts/{jasmine.headless-reporter_spec.coffee → jasmine.HeadlessConsoleReporter_spec.coffee} +2 -2
- data/spec/javascripts/support/jasmine.yml +1 -1
- data/spec/lib/jasmine/files_list_spec.rb +6 -3
- data/spec/lib/jasmine/headless/spec_file_analyzer_spec.rb +41 -30
- data/spec/lib/qt/qmake_spec.rb +0 -6
- data/vendor/assets/coffeescripts/headless_reporter_result.coffee +46 -0
- data/vendor/assets/coffeescripts/intense.coffee +27 -0
- data/{jasmine/jasmine.headless-reporter.coffee → vendor/assets/coffeescripts/jasmine-extensions.coffee} +5 -90
- data/vendor/assets/coffeescripts/jasmine.HeadlessConsoleReporter.coffee +86 -0
- data/vendor/assets/coffeescripts/prolog.coffee +73 -0
- data/{js-lib → vendor/assets/javascripts}/beautify-html.js +0 -0
- data/vendor/assets/javascripts/headless_reporter_result.js +72 -0
- data/vendor/assets/javascripts/intense.js +37 -0
- data/vendor/assets/javascripts/jasmine-extensions.js +101 -0
- data/vendor/assets/javascripts/jasmine.HeadlessConsoleReporter.js +96 -0
- data/{js-lib → vendor/assets/javascripts}/jsDump.js +0 -0
- data/vendor/assets/javascripts/prolog.js +89 -0
- metadata +28 -33
- data/dev-bin/hooks/pre-commit +0 -5
- data/dev-bin/install-hooks +0 -6
- data/ext/jasmine-webkit-specrunner/ConsoleOutput.cpp +0 -149
- data/ext/jasmine-webkit-specrunner/ConsoleOutput.h +0 -39
- data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.cpp +0 -129
- data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.h +0 -32
- data/ext/jasmine-webkit-specrunner/ConsoleOutput_test.pro +0 -7
- data/ext/jasmine-webkit-specrunner/Page_test.cpp +0 -43
- data/ext/jasmine-webkit-specrunner/Page_test.h +0 -27
- data/ext/jasmine-webkit-specrunner/Page_test.pro +0 -6
- data/ext/jasmine-webkit-specrunner/ReportFileOutput.cpp +0 -54
- data/ext/jasmine-webkit-specrunner/ReportFileOutput.h +0 -37
- data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.cpp +0 -88
- data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.h +0 -26
- data/ext/jasmine-webkit-specrunner/ReportFileOutput_test.pro +0 -7
- data/ext/jasmine-webkit-specrunner/test.pri +0 -3
- data/ext/jasmine-webkit-specrunner/test.rb +0 -31
- data/jasmine/jasmine.headless-reporter.js +0 -231
data/Guardfile
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# watch('file/path') { `command(s)` }
|
4
4
|
#
|
5
5
|
|
6
|
+
guard 'coffeescript', :input => 'vendor/assets/coffeescripts', :output => 'vendor/assets/javascripts'
|
7
|
+
|
6
8
|
guard 'shell' do
|
7
9
|
watch(%r{ext/jasmine-webkit-specrunner/.*\.(cpp|h|pro|pri)}) { |m|
|
8
10
|
if !m[0]['moc_']
|
@@ -27,9 +29,8 @@ end
|
|
27
29
|
|
28
30
|
def compile
|
29
31
|
#system %{cd ext/jasmine-webkit-specrunner && ruby test.rb && ruby extconf.rb}
|
30
|
-
system %{cd ext/jasmine-webkit-specrunner && ruby
|
32
|
+
system %{cd ext/jasmine-webkit-specrunner && ruby extconf.rb}
|
31
33
|
end
|
32
34
|
|
33
35
|
compile
|
34
36
|
|
35
|
-
guard 'coffeescript', :input => 'jasmine'
|
data/bin/jasmine-headless-webkit
CHANGED
@@ -9,6 +9,7 @@ end
|
|
9
9
|
|
10
10
|
$:.unshift(File.join(gem_dir, 'lib'))
|
11
11
|
require 'jasmine-headless-webkit'
|
12
|
+
require 'coffee-script'
|
12
13
|
|
13
14
|
begin
|
14
15
|
options = Jasmine::Headless::Options.from_command_line
|
@@ -18,7 +19,6 @@ begin
|
|
18
19
|
files_list = Jasmine::FilesList.new(:config => runner.jasmine_config)
|
19
20
|
files_list.files.each { |file| puts file }
|
20
21
|
else
|
21
|
-
puts "Running Jasmine specs...".color(:white)
|
22
22
|
exit runner.run
|
23
23
|
end
|
24
24
|
rescue CoffeeScript::CompilationError
|
@@ -4,26 +4,13 @@
|
|
4
4
|
|
5
5
|
#include "Page.h"
|
6
6
|
|
7
|
-
|
7
|
+
Page::Page() : QWebPage() {}
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
void Page::javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID) {
|
10
|
+
emit handleError(message, lineNumber, sourceID);
|
11
|
+
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
} else {
|
18
|
-
confirmResult = true;
|
19
|
-
return false;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
void Page::javaScriptAlert(QWebFrame*, const QString &msg) {
|
24
|
-
emit internalLog("alert", msg);
|
25
|
-
}
|
26
|
-
|
27
|
-
void Page::oneFalseConfirm() {
|
28
|
-
confirmResult = false;
|
29
|
-
}
|
13
|
+
void Page::javaScriptAlert(QWebFrame *, const QString &) {}
|
14
|
+
bool Page::javaScriptConfirm(QWebFrame *, const QString &) {
|
15
|
+
return false;
|
16
|
+
}
|
@@ -4,20 +4,16 @@
|
|
4
4
|
#include <QtGui>
|
5
5
|
#include <QtWebKit>
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
void javaScriptAlert(QWebFrame *frame, const QString &msg);
|
19
|
-
private:
|
20
|
-
bool confirmResult;
|
21
|
-
};
|
7
|
+
class Page: public QWebPage {
|
8
|
+
Q_OBJECT
|
9
|
+
public:
|
10
|
+
Page();
|
11
|
+
protected:
|
12
|
+
void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID);
|
13
|
+
void javaScriptAlert(QWebFrame *, const QString &);
|
14
|
+
bool javaScriptConfirm(QWebFrame *, const QString &);
|
15
|
+
signals:
|
16
|
+
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
17
|
+
};
|
22
18
|
|
23
19
|
#endif
|
@@ -3,181 +3,157 @@
|
|
3
3
|
#include <QFile>
|
4
4
|
#include <QTextStream>
|
5
5
|
#include <iostream>
|
6
|
+
#include <sstream>
|
6
7
|
#include <QQueue>
|
7
8
|
|
8
9
|
#include "Runner.h"
|
10
|
+
#include "Page.h"
|
9
11
|
|
10
12
|
using namespace std;
|
11
13
|
|
12
14
|
Runner::Runner() : QObject()
|
13
|
-
,
|
15
|
+
, runs(0)
|
14
16
|
, hasErrors(false)
|
17
|
+
, _hasSpecFailure(false)
|
15
18
|
, usedConsole(false)
|
16
19
|
, isFinished(false)
|
17
|
-
,
|
20
|
+
, useColors(false)
|
18
21
|
{
|
19
|
-
|
20
|
-
|
22
|
+
page.settings()->enablePersistentStorage();
|
23
|
+
ticker.setInterval(TIMER_TICK);
|
21
24
|
|
22
|
-
connect(&
|
23
|
-
connect(&
|
24
|
-
connect(&
|
25
|
-
connect(
|
26
|
-
connect(m_page.mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJHW()));
|
25
|
+
connect(&ticker, SIGNAL(timeout()), this, SLOT(timerEvent()));
|
26
|
+
connect(&page, SIGNAL(loadFinished(bool)), this, SLOT(watch(bool)));
|
27
|
+
connect(&page, SIGNAL(handleError(const QString &, int, const QString &)), this, SLOT(handleError(const QString &, int, const QString &)));
|
28
|
+
connect(page.mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJHW()));
|
27
29
|
}
|
28
30
|
|
29
31
|
void Runner::addFile(const QString &spec) {
|
30
32
|
runnerFiles.enqueue(spec);
|
31
33
|
}
|
32
34
|
|
33
|
-
void Runner::go()
|
34
|
-
|
35
|
-
|
36
|
-
m_page.setPreferredContentsSize(QSize(1024, 600));
|
35
|
+
void Runner::go() {
|
36
|
+
ticker.stop();
|
37
|
+
page.setPreferredContentsSize(QSize(1024, 600));
|
37
38
|
addJHW();
|
38
|
-
loadSpec();
|
39
39
|
|
40
|
-
|
40
|
+
loadSpec();
|
41
41
|
}
|
42
|
-
void Runner::addJHW()
|
43
|
-
|
44
|
-
|
42
|
+
void Runner::addJHW() {
|
43
|
+
page.mainFrame()->addToJavaScriptWindowObject("JHW", this);
|
44
|
+
}
|
45
|
+
|
46
|
+
void Runner::handleError(const QString &message, int lineNumber, const QString &sourceID) {
|
47
|
+
QString messageEscaped = QString(message);
|
48
|
+
QString sourceIDEscaped = QString(sourceID);
|
49
|
+
|
50
|
+
messageEscaped.replace(QString("\""), QString("\\\""));
|
51
|
+
sourceIDEscaped.replace(QString("\""), QString("\\\""));
|
52
|
+
|
53
|
+
std::stringstream ss;
|
54
|
+
ss << lineNumber;
|
55
|
+
|
56
|
+
QString command("JHW._handleError(\"" + messageEscaped + "\", " + QString(ss.str().c_str()) + ", \"" + sourceIDEscaped + "\"); false;");
|
57
|
+
|
58
|
+
page.mainFrame()->evaluateJavaScript(command);
|
59
|
+
|
60
|
+
hasErrors = true;
|
45
61
|
}
|
46
62
|
|
47
63
|
void Runner::loadSpec()
|
48
64
|
{
|
49
|
-
|
50
|
-
|
65
|
+
if (reportFileName.isEmpty()) {
|
66
|
+
outputFile = 0;
|
67
|
+
ts = 0;
|
68
|
+
} else {
|
69
|
+
outputFile = new QFile(reportFileName);
|
70
|
+
outputFile->open(QIODevice::WriteOnly);
|
71
|
+
|
72
|
+
ts = new QTextStream(outputFile);
|
73
|
+
}
|
74
|
+
|
75
|
+
page.mainFrame()->load(runnerFiles.dequeue());
|
76
|
+
ticker.start();
|
51
77
|
}
|
52
78
|
|
53
|
-
void Runner::watch(bool ok)
|
54
|
-
{
|
79
|
+
void Runner::watch(bool ok) {
|
55
80
|
if (!ok) {
|
56
|
-
std::cerr << "Can't load " << qPrintable(
|
81
|
+
std::cerr << "Can't load " << qPrintable(page.mainFrame()->url().toString()) << ", the file may be broken." << std::endl;
|
57
82
|
std::cerr << "Out of curiosity, did your tests try to submit a form and you haven't prevented that?" << std::endl;
|
58
83
|
std::cerr << "Try running your tests in your browser with the Jasmine server and see what happens." << std::endl;
|
59
84
|
QApplication::instance()->exit(1);
|
60
85
|
return;
|
61
86
|
}
|
62
87
|
|
63
|
-
|
64
|
-
|
65
|
-
bool Runner::hasElement(const char *select)
|
66
|
-
{
|
67
|
-
return !m_page.mainFrame()->findFirstElement(select).isNull();
|
88
|
+
page.mainFrame()->evaluateJavaScript(QString("JHW._setColors(") + (useColors ? QString("true") : QString("false")) + QString("); false;"));
|
68
89
|
}
|
69
90
|
|
70
91
|
void Runner::setColors(bool colors) {
|
71
|
-
|
92
|
+
useColors = colors;
|
72
93
|
}
|
73
94
|
|
74
|
-
void Runner::
|
75
|
-
|
76
|
-
}
|
77
|
-
|
78
|
-
bool Runner::hasError() {
|
79
|
-
return hasErrors;
|
80
|
-
}
|
81
|
-
|
82
|
-
void Runner::timerPause() {
|
83
|
-
m_ticker.stop();
|
84
|
-
}
|
85
|
-
|
86
|
-
void Runner::timerDone() {
|
87
|
-
m_ticker.start();
|
88
|
-
}
|
89
|
-
|
90
|
-
void Runner::specPassed(const QString &specDetail) {
|
91
|
-
consoleOutput.passed(specDetail);
|
92
|
-
reportFileOutput.passed(specDetail);
|
93
|
-
}
|
94
|
-
|
95
|
-
void Runner::specFailed(const QString &specDetail) {
|
96
|
-
consoleOutput.failed(specDetail);
|
97
|
-
reportFileOutput.failed(specDetail);
|
98
|
-
|
99
|
-
didFail = true;
|
100
|
-
failedSpecs.push(specDetail);
|
95
|
+
void Runner::hasUsedConsole() {
|
96
|
+
usedConsole = true;
|
101
97
|
}
|
102
98
|
|
103
|
-
void Runner::
|
104
|
-
{
|
105
|
-
consoleOutput.errorLog(msg, lineNumber, sourceID);
|
106
|
-
reportFileOutput.errorLog(msg, lineNumber, sourceID);
|
107
|
-
|
99
|
+
void Runner::hasError() {
|
108
100
|
hasErrors = true;
|
109
|
-
m_runs = 0;
|
110
|
-
m_ticker.start();
|
111
101
|
}
|
112
102
|
|
113
|
-
void Runner::
|
114
|
-
|
115
|
-
reportFileOutput.internalLog(note, msg);
|
103
|
+
void Runner::hasSpecFailure() {
|
104
|
+
_hasSpecFailure = true;
|
116
105
|
}
|
117
106
|
|
118
|
-
void Runner::
|
119
|
-
|
120
|
-
usedConsole = true;
|
121
|
-
consoleOutput.consoleLog(msg);
|
122
|
-
reportFileOutput.consoleLog(msg);
|
107
|
+
void Runner::reportFile(const QString &file) {
|
108
|
+
reportFileName = file;
|
123
109
|
}
|
124
110
|
|
125
|
-
void Runner::
|
126
|
-
|
127
|
-
consoleOutput.internalLog("error", msg);
|
128
|
-
m_page.oneFalseConfirm();
|
129
|
-
hasErrors = true;
|
111
|
+
void Runner::timerPause() {
|
112
|
+
ticker.stop();
|
130
113
|
}
|
131
114
|
|
132
|
-
void Runner::
|
133
|
-
|
134
|
-
consoleOutput.logSpecFilename(name);
|
115
|
+
void Runner::timerDone() {
|
116
|
+
ticker.start();
|
135
117
|
}
|
136
118
|
|
137
|
-
void Runner::
|
138
|
-
|
139
|
-
consoleOutput.logSpecResult(result);
|
119
|
+
void Runner::ping() {
|
120
|
+
runs = 0;
|
140
121
|
}
|
141
122
|
|
142
|
-
void Runner::
|
143
|
-
{
|
144
|
-
|
145
|
-
|
146
|
-
reportFileOutput.reportFailure(total, failed, duration);
|
147
|
-
} else {
|
148
|
-
if (hasErrors) {
|
149
|
-
consoleOutput.reportSuccessWithJSErrors(total, failed, duration);
|
150
|
-
reportFileOutput.reportSuccessWithJSErrors(total, failed, duration);
|
151
|
-
} else {
|
152
|
-
consoleOutput.reportSuccess(total, failed, duration);
|
153
|
-
reportFileOutput.reportSuccess(total, failed, duration);
|
154
|
-
}
|
123
|
+
void Runner::print(const QString &fh, const QString &content) {
|
124
|
+
if (fh == "stdout") {
|
125
|
+
std::cout << qPrintable(content);
|
126
|
+
std::cout.flush();
|
155
127
|
}
|
156
128
|
|
157
|
-
if (
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
QTextStream ts(&outputFile);
|
162
|
-
|
163
|
-
ts << reportFileOutput.outputIO->str().c_str();
|
129
|
+
if (fh == "stderr") {
|
130
|
+
std::cerr << qPrintable(content);
|
131
|
+
std::cerr.flush();
|
132
|
+
}
|
164
133
|
|
165
|
-
|
134
|
+
if (fh == "report" && outputFile) {
|
135
|
+
*ts << qPrintable(content);
|
136
|
+
ts->flush();
|
166
137
|
}
|
138
|
+
}
|
167
139
|
|
140
|
+
void Runner::finishSuite() {
|
168
141
|
isFinished = true;
|
169
142
|
}
|
170
143
|
|
171
|
-
void Runner::timerEvent()
|
172
|
-
|
173
|
-
++m_runs;
|
144
|
+
void Runner::timerEvent() {
|
145
|
+
++runs;
|
174
146
|
|
175
|
-
if (hasErrors &&
|
147
|
+
if (hasErrors && runs > 2)
|
176
148
|
QApplication::instance()->exit(1);
|
177
149
|
|
178
150
|
if (isFinished) {
|
151
|
+
if (outputFile) {
|
152
|
+
outputFile->close();
|
153
|
+
}
|
154
|
+
|
179
155
|
int exitCode = 0;
|
180
|
-
if (
|
156
|
+
if (_hasSpecFailure || hasErrors) {
|
181
157
|
exitCode = 1;
|
182
158
|
} else {
|
183
159
|
if (usedConsole) {
|
@@ -203,8 +179,8 @@ void Runner::timerEvent()
|
|
203
179
|
}
|
204
180
|
}
|
205
181
|
|
206
|
-
if (
|
207
|
-
std::
|
182
|
+
if (runs > MAX_LOOPS) {
|
183
|
+
std::cerr << "WARNING: too many runs and the test is still not finished!" << std::endl;
|
208
184
|
QApplication::instance()->exit(1);
|
209
185
|
}
|
210
186
|
}
|
@@ -10,57 +10,54 @@
|
|
10
10
|
#include <QQueue>
|
11
11
|
|
12
12
|
#include "Page.h"
|
13
|
-
#include "ConsoleOutput.h"
|
14
|
-
#include "ReportFileOutput.h"
|
15
13
|
|
16
14
|
using namespace std;
|
17
15
|
|
18
16
|
class Runner: public QObject {
|
19
17
|
Q_OBJECT
|
20
18
|
public:
|
21
|
-
enum { TIMER_TICK = 200, MAX_LOOPS =
|
19
|
+
enum { TIMER_TICK = 200, MAX_LOOPS = 50 };
|
22
20
|
|
23
21
|
Runner();
|
24
22
|
void setColors(bool colors);
|
25
23
|
void reportFile(const QString &file);
|
26
24
|
void addFile(const QString &spec);
|
27
25
|
void go();
|
28
|
-
|
29
|
-
|
30
|
-
bool hasError();
|
31
|
-
void leavePageAttempt(const QString &msg);
|
26
|
+
|
27
|
+
public slots:
|
32
28
|
void timerPause();
|
33
29
|
void timerDone();
|
34
|
-
void
|
35
|
-
void
|
36
|
-
void
|
37
|
-
void
|
38
|
-
void finishSuite(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
void
|
30
|
+
void hasUsedConsole();
|
31
|
+
void hasError();
|
32
|
+
void hasSpecFailure();
|
33
|
+
void print(const QString &fh, const QString &content);
|
34
|
+
void finishSuite();
|
35
|
+
void ping();
|
36
|
+
|
37
|
+
private slots:
|
38
|
+
void watch(bool ok);
|
43
39
|
void addJHW();
|
44
40
|
void timerEvent();
|
45
|
-
|
46
|
-
|
41
|
+
void handleError(const QString & message, int lineNumber, const QString & sourceID);
|
42
|
+
|
47
43
|
private:
|
48
|
-
Page
|
49
|
-
QTimer
|
50
|
-
int
|
44
|
+
Page page;
|
45
|
+
QTimer ticker;
|
46
|
+
int runs;
|
51
47
|
bool hasErrors;
|
48
|
+
bool _hasSpecFailure;
|
52
49
|
bool usedConsole;
|
53
50
|
bool isFinished;
|
54
|
-
bool
|
55
|
-
QQueue<QString> runnerFiles;
|
56
|
-
QStack<QString> failedSpecs;
|
51
|
+
bool useColors;
|
57
52
|
|
58
|
-
|
59
|
-
ReportFileOutput reportFileOutput;
|
53
|
+
QQueue<QString> runnerFiles;
|
60
54
|
|
61
55
|
QString reportFileName;
|
62
56
|
|
63
57
|
void loadSpec();
|
58
|
+
|
59
|
+
QFile *outputFile;
|
60
|
+
QTextStream *ts;
|
64
61
|
};
|
65
62
|
|
66
63
|
#endif
|