mocha 2.3.0 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +49 -2
- package/bin/_mocha +1 -9
- package/bin/mocha +3 -24
- package/lib/browser/diff.js +369 -0
- package/lib/hook.js +2 -5
- package/lib/mocha.js +1 -1
- package/lib/reporters/base.js +9 -2
- package/lib/reporters/dot.js +2 -5
- package/lib/reporters/landing.js +2 -5
- package/lib/reporters/list.js +2 -5
- package/lib/reporters/markdown.js +1 -1
- package/lib/reporters/min.js +2 -5
- package/lib/reporters/nyan.js +2 -5
- package/lib/reporters/progress.js +2 -5
- package/lib/reporters/spec.js +2 -5
- package/lib/reporters/templates/coverage.jade +2 -2
- package/lib/reporters/templates/menu.jade +3 -3
- package/lib/reporters/xunit.js +8 -10
- package/lib/runnable.js +2 -5
- package/lib/runner.js +36 -19
- package/lib/suite.js +3 -6
- package/lib/test.js +2 -5
- package/lib/utils.js +9 -11
- package/mocha.js +263 -1156
- package/package.json +4 -5
package/HISTORY.md
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
1
|
|
|
2
|
+
2.3.4 / 2015-11-15
|
|
3
|
+
==================
|
|
4
|
+
|
|
5
|
+
* Update debug dependency to 2.2.0
|
|
6
|
+
* remove duplication of mocha.opts on process.argv
|
|
7
|
+
* Fix typo in test/reporters/nyan.js
|
|
8
|
+
|
|
9
|
+
2.3.3 / 2015-09-19
|
|
10
|
+
==================
|
|
11
|
+
|
|
12
|
+
* [#1875] - Fix Markdown reporter exceeds maximum call stack size ([@danielstjules])
|
|
13
|
+
* [#1864] - Fix xunit missing output with --reporter-options output ([@danielstjules])
|
|
14
|
+
* [#1846] - Support all harmony flags ([@danielstjules])
|
|
15
|
+
* Fix fragile xunit reporter spec ([@danielstjules])
|
|
16
|
+
* [#1669] - Fix catch uncaught errors outside test suite execution ([@danielstjules])
|
|
17
|
+
* [#1868] - Revert jade to support npm < v1.3.7 ([@danielstjules])
|
|
18
|
+
* [#1766] - Don't remove modules/components from stack trace in the browser ([@danielstjules])
|
|
19
|
+
* [#1798] - Fix correctly attribute mutiple done err with hooks ([@danielstjules])
|
|
20
|
+
* Fix use utils.reduce for IE8 compatibility ([@wsw0108])
|
|
21
|
+
* Some linting errors fixed by [@danielstjules]
|
|
22
|
+
* Call the inspect() function if message is not set ([@kevinburke])
|
|
23
|
+
|
|
24
|
+
[#1875]: https://github.com/mochajs/mocha/issues/1875
|
|
25
|
+
[#1864]: https://github.com/mochajs/mocha/issues/1864
|
|
26
|
+
[#1846]: https://github.com/mochajs/mocha/issues/1846
|
|
27
|
+
[#1669]: https://github.com/mochajs/mocha/issues/1669
|
|
28
|
+
[#1868]: https://github.com/mochajs/mocha/issues/1868
|
|
29
|
+
[#1766]: https://github.com/mochajs/mocha/issues/1766
|
|
30
|
+
[#1798]: https://github.com/mochajs/mocha/issues/1798
|
|
31
|
+
[@danielstjules]: https://github.com/danielstjules
|
|
32
|
+
[@wsw0108]: https://github.com/wsw0108
|
|
33
|
+
[@kevinburke]: https://github.com/kevinburke
|
|
34
|
+
|
|
35
|
+
2.3.2 / 2015-09-07
|
|
36
|
+
==================
|
|
37
|
+
* [#1868] - Fix compatibility with older versions of NPM ([@boneskull])
|
|
38
|
+
|
|
39
|
+
[#1868]: https://github.com/mochajs/mocha/issues/1868
|
|
40
|
+
|
|
41
|
+
2.3.1 / 2015-09-06
|
|
42
|
+
==================
|
|
43
|
+
|
|
44
|
+
* [#1812] - Fix: Bail flag causes before() hooks to be run even after a failure ([@aaroncrows])
|
|
45
|
+
|
|
46
|
+
[#1812]: https://github.com/mochajs/mocha/issues/1812
|
|
47
|
+
[aaroncrows]: https://github.com/aaroncrows
|
|
48
|
+
|
|
2
49
|
2.3.0 / 2015-08-30
|
|
3
50
|
==================
|
|
4
51
|
|
|
@@ -10,7 +57,7 @@
|
|
|
10
57
|
* [#1230] - More descriptive beforeEach/afterEach messages ([@duncanbeevers])
|
|
11
58
|
* [#1787] - Scope loading behaviour instead of using early return ([@aryeguy])
|
|
12
59
|
* [#1789] - Fix: html-runner crashing ([@sunesimonsen])
|
|
13
|
-
* [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho])
|
|
60
|
+
* [#1749] - Fix maximum call stack error on large amount of tests ([@tinganho])
|
|
14
61
|
* [#1230] - Decorate failed hook titles with test title ([@duncanbeevers])
|
|
15
62
|
* [#1260] - Build using Browserify ([@ndhoule])
|
|
16
63
|
* [#1728] - Don't use `__proto__` ([@ndhoule])
|
|
@@ -19,7 +66,7 @@
|
|
|
19
66
|
* [#1766] - Fix overly aggressive stack suppression ([@moll])
|
|
20
67
|
* [#1752] - Avoid potential infinite loop ([@gsilk])
|
|
21
68
|
* [#1761] - Fix problems running under PhantomJS ([@chromakode])
|
|
22
|
-
* [#1700] - Fix more problems running under PhantomJS ([@jbnicolai])
|
|
69
|
+
* [#1700] - Fix more problems running under PhantomJS ([@jbnicolai])
|
|
23
70
|
* [#1774] - Support escaped spaces in CLI options ([@adamgruber])
|
|
24
71
|
* [#1687] - Fix HTML reporter links with special chars ([@benvinegar])
|
|
25
72
|
* [#1359] - Adopt code style and enforce it using ESLint ([@ndhoule] w/ assist from [@jbnicolai] & [@boneskull])
|
package/bin/_mocha
CHANGED
|
@@ -81,16 +81,8 @@ program
|
|
|
81
81
|
.option('--compilers <ext>:<module>,...', 'use the given module(s) to compile files', list, [])
|
|
82
82
|
.option('--debug-brk', "enable node's debugger breaking on the first line")
|
|
83
83
|
.option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])
|
|
84
|
-
.option('--harmony', 'enable all harmony features (except typeof)')
|
|
85
84
|
.option('--es_staging', 'enable all staged features')
|
|
86
|
-
.option('--harmony
|
|
87
|
-
.option('--harmony-generators', 'enable harmony generators')
|
|
88
|
-
.option('--harmony-proxies', 'enable harmony proxies')
|
|
89
|
-
.option('--harmony_shipping', 'enable all shipped harmony fetaures (iojs)')
|
|
90
|
-
.option('--harmony_arrow_functions', 'enable "harmony arrow functions" (iojs)')
|
|
91
|
-
.option('--harmony_rest_parameters', 'enable "harmony rest parameters" (iojs)')
|
|
92
|
-
.option('--harmony_proxies', 'enable "harmony proxies" (iojs)')
|
|
93
|
-
.option('--harmony_classes', 'enable "harmony classes" (iojs)')
|
|
85
|
+
.option('--harmony<_classes,_generators,...>', 'all node --harmony* flags are available')
|
|
94
86
|
.option('--inline-diffs', 'display actual/expected differences inline within each string')
|
|
95
87
|
.option('--interfaces', 'display available interfaces')
|
|
96
88
|
.option('--no-deprecation', 'silence deprecation warnings')
|
package/bin/mocha
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
var spawn = require('child_process').spawn,
|
|
9
9
|
path = require('path'),
|
|
10
10
|
fs = require('fs'),
|
|
11
|
-
args = [path.join(__dirname, '_mocha')]
|
|
12
|
-
getOptions = require('./options');
|
|
13
|
-
|
|
14
|
-
// load mocha.opts into process.argv
|
|
15
|
-
|
|
16
|
-
getOptions();
|
|
11
|
+
args = [path.join(__dirname, '_mocha')];
|
|
17
12
|
|
|
18
13
|
process.argv.slice(2).forEach(function(arg){
|
|
19
14
|
var flag = arg.split('=')[0];
|
|
@@ -34,24 +29,7 @@ process.argv.slice(2).forEach(function(arg){
|
|
|
34
29
|
args.unshift('--expose-gc');
|
|
35
30
|
break;
|
|
36
31
|
case '--gc-global':
|
|
37
|
-
case '--harmony':
|
|
38
32
|
case '--es_staging':
|
|
39
|
-
case '--harmony_arrays':
|
|
40
|
-
case '--harmony_array_includes':
|
|
41
|
-
case '--harmony_arrow_functions':
|
|
42
|
-
case '--harmony_classes':
|
|
43
|
-
case '--harmony-collections':
|
|
44
|
-
case '--harmony_collections':
|
|
45
|
-
case '--harmony-generators':
|
|
46
|
-
case '--harmony_generators':
|
|
47
|
-
case '--harmony_modules':
|
|
48
|
-
case '--harmony-proxies':
|
|
49
|
-
case '--harmony_proxies':
|
|
50
|
-
case '--harmony_regexps':
|
|
51
|
-
case '--harmony_shipping':
|
|
52
|
-
case '--harmony_sloppy':
|
|
53
|
-
case '--harmony_rest_parameters':
|
|
54
|
-
case '--harmony_unicode':
|
|
55
33
|
case '--no-deprecation':
|
|
56
34
|
case '--prof':
|
|
57
35
|
case '--throw-deprecation':
|
|
@@ -60,7 +38,8 @@ process.argv.slice(2).forEach(function(arg){
|
|
|
60
38
|
args.unshift(arg);
|
|
61
39
|
break;
|
|
62
40
|
default:
|
|
63
|
-
if (0 == arg.indexOf('--
|
|
41
|
+
if (0 == arg.indexOf('--harmony')) args.unshift(arg);
|
|
42
|
+
else if (0 == arg.indexOf('--trace')) args.unshift(arg);
|
|
64
43
|
else if (0 == arg.indexOf('--max-old-space-size')) args.unshift(arg);
|
|
65
44
|
else args.push(arg);
|
|
66
45
|
break;
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/* See LICENSE file for terms of use */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Text diff implementation.
|
|
5
|
+
*
|
|
6
|
+
* This library supports the following APIS:
|
|
7
|
+
* JsDiff.diffChars: Character by character diff
|
|
8
|
+
* JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace
|
|
9
|
+
* JsDiff.diffLines: Line based diff
|
|
10
|
+
*
|
|
11
|
+
* JsDiff.diffCss: Diff targeted at CSS content
|
|
12
|
+
*
|
|
13
|
+
* These methods are based on the implementation proposed in
|
|
14
|
+
* "An O(ND) Difference Algorithm and its Variations" (Myers, 1986).
|
|
15
|
+
* http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927
|
|
16
|
+
*/
|
|
17
|
+
var JsDiff = (function() {
|
|
18
|
+
/*jshint maxparams: 5*/
|
|
19
|
+
function clonePath(path) {
|
|
20
|
+
return { newPos: path.newPos, components: path.components.slice(0) };
|
|
21
|
+
}
|
|
22
|
+
function removeEmpty(array) {
|
|
23
|
+
var ret = [];
|
|
24
|
+
for (var i = 0; i < array.length; i++) {
|
|
25
|
+
if (array[i]) {
|
|
26
|
+
ret.push(array[i]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return ret;
|
|
30
|
+
}
|
|
31
|
+
function escapeHTML(s) {
|
|
32
|
+
var n = s;
|
|
33
|
+
n = n.replace(/&/g, '&');
|
|
34
|
+
n = n.replace(/</g, '<');
|
|
35
|
+
n = n.replace(/>/g, '>');
|
|
36
|
+
n = n.replace(/"/g, '"');
|
|
37
|
+
|
|
38
|
+
return n;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var Diff = function(ignoreWhitespace) {
|
|
42
|
+
this.ignoreWhitespace = ignoreWhitespace;
|
|
43
|
+
};
|
|
44
|
+
Diff.prototype = {
|
|
45
|
+
diff: function(oldString, newString) {
|
|
46
|
+
// Handle the identity case (this is due to unrolling editLength == 0
|
|
47
|
+
if (newString === oldString) {
|
|
48
|
+
return [{ value: newString }];
|
|
49
|
+
}
|
|
50
|
+
if (!newString) {
|
|
51
|
+
return [{ value: oldString, removed: true }];
|
|
52
|
+
}
|
|
53
|
+
if (!oldString) {
|
|
54
|
+
return [{ value: newString, added: true }];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
newString = this.tokenize(newString);
|
|
58
|
+
oldString = this.tokenize(oldString);
|
|
59
|
+
|
|
60
|
+
var newLen = newString.length, oldLen = oldString.length;
|
|
61
|
+
var maxEditLength = newLen + oldLen;
|
|
62
|
+
var bestPath = [{ newPos: -1, components: [] }];
|
|
63
|
+
|
|
64
|
+
// Seed editLength = 0
|
|
65
|
+
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
|
|
66
|
+
if (bestPath[0].newPos+1 >= newLen && oldPos+1 >= oldLen) {
|
|
67
|
+
return bestPath[0].components;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (var editLength = 1; editLength <= maxEditLength; editLength++) {
|
|
71
|
+
for (var diagonalPath = -1*editLength; diagonalPath <= editLength; diagonalPath+=2) {
|
|
72
|
+
var basePath;
|
|
73
|
+
var addPath = bestPath[diagonalPath-1],
|
|
74
|
+
removePath = bestPath[diagonalPath+1];
|
|
75
|
+
oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
|
|
76
|
+
if (addPath) {
|
|
77
|
+
// No one else is going to attempt to use this value, clear it
|
|
78
|
+
bestPath[diagonalPath-1] = undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var canAdd = addPath && addPath.newPos+1 < newLen;
|
|
82
|
+
var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
|
|
83
|
+
if (!canAdd && !canRemove) {
|
|
84
|
+
bestPath[diagonalPath] = undefined;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Select the diagonal that we want to branch from. We select the prior
|
|
89
|
+
// path whose position in the new string is the farthest from the origin
|
|
90
|
+
// and does not pass the bounds of the diff graph
|
|
91
|
+
if (!canAdd || (canRemove && addPath.newPos < removePath.newPos)) {
|
|
92
|
+
basePath = clonePath(removePath);
|
|
93
|
+
this.pushComponent(basePath.components, oldString[oldPos], undefined, true);
|
|
94
|
+
} else {
|
|
95
|
+
basePath = clonePath(addPath);
|
|
96
|
+
basePath.newPos++;
|
|
97
|
+
this.pushComponent(basePath.components, newString[basePath.newPos], true, undefined);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var oldPos = this.extractCommon(basePath, newString, oldString, diagonalPath);
|
|
101
|
+
|
|
102
|
+
if (basePath.newPos+1 >= newLen && oldPos+1 >= oldLen) {
|
|
103
|
+
return basePath.components;
|
|
104
|
+
} else {
|
|
105
|
+
bestPath[diagonalPath] = basePath;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
pushComponent: function(components, value, added, removed) {
|
|
112
|
+
var last = components[components.length-1];
|
|
113
|
+
if (last && last.added === added && last.removed === removed) {
|
|
114
|
+
// We need to clone here as the component clone operation is just
|
|
115
|
+
// as shallow array clone
|
|
116
|
+
components[components.length-1] =
|
|
117
|
+
{value: this.join(last.value, value), added: added, removed: removed };
|
|
118
|
+
} else {
|
|
119
|
+
components.push({value: value, added: added, removed: removed });
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
extractCommon: function(basePath, newString, oldString, diagonalPath) {
|
|
123
|
+
var newLen = newString.length,
|
|
124
|
+
oldLen = oldString.length,
|
|
125
|
+
newPos = basePath.newPos,
|
|
126
|
+
oldPos = newPos - diagonalPath;
|
|
127
|
+
while (newPos+1 < newLen && oldPos+1 < oldLen && this.equals(newString[newPos+1], oldString[oldPos+1])) {
|
|
128
|
+
newPos++;
|
|
129
|
+
oldPos++;
|
|
130
|
+
|
|
131
|
+
this.pushComponent(basePath.components, newString[newPos], undefined, undefined);
|
|
132
|
+
}
|
|
133
|
+
basePath.newPos = newPos;
|
|
134
|
+
return oldPos;
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
equals: function(left, right) {
|
|
138
|
+
var reWhitespace = /\S/;
|
|
139
|
+
if (this.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right)) {
|
|
140
|
+
return true;
|
|
141
|
+
} else {
|
|
142
|
+
return left === right;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
join: function(left, right) {
|
|
146
|
+
return left + right;
|
|
147
|
+
},
|
|
148
|
+
tokenize: function(value) {
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
var CharDiff = new Diff();
|
|
154
|
+
|
|
155
|
+
var WordDiff = new Diff(true);
|
|
156
|
+
var WordWithSpaceDiff = new Diff();
|
|
157
|
+
WordDiff.tokenize = WordWithSpaceDiff.tokenize = function(value) {
|
|
158
|
+
return removeEmpty(value.split(/(\s+|\b)/));
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
var CssDiff = new Diff(true);
|
|
162
|
+
CssDiff.tokenize = function(value) {
|
|
163
|
+
return removeEmpty(value.split(/([{}:;,]|\s+)/));
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var LineDiff = new Diff();
|
|
167
|
+
LineDiff.tokenize = function(value) {
|
|
168
|
+
var retLines = [],
|
|
169
|
+
lines = value.split(/^/m);
|
|
170
|
+
|
|
171
|
+
for(var i = 0; i < lines.length; i++) {
|
|
172
|
+
var line = lines[i],
|
|
173
|
+
lastLine = lines[i - 1];
|
|
174
|
+
|
|
175
|
+
// Merge lines that may contain windows new lines
|
|
176
|
+
if (line == '\n' && lastLine && lastLine[lastLine.length - 1] === '\r') {
|
|
177
|
+
retLines[retLines.length - 1] += '\n';
|
|
178
|
+
} else if (line) {
|
|
179
|
+
retLines.push(line);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return retLines;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
Diff: Diff,
|
|
188
|
+
|
|
189
|
+
diffChars: function(oldStr, newStr) { return CharDiff.diff(oldStr, newStr); },
|
|
190
|
+
diffWords: function(oldStr, newStr) { return WordDiff.diff(oldStr, newStr); },
|
|
191
|
+
diffWordsWithSpace: function(oldStr, newStr) { return WordWithSpaceDiff.diff(oldStr, newStr); },
|
|
192
|
+
diffLines: function(oldStr, newStr) { return LineDiff.diff(oldStr, newStr); },
|
|
193
|
+
|
|
194
|
+
diffCss: function(oldStr, newStr) { return CssDiff.diff(oldStr, newStr); },
|
|
195
|
+
|
|
196
|
+
createPatch: function(fileName, oldStr, newStr, oldHeader, newHeader) {
|
|
197
|
+
var ret = [];
|
|
198
|
+
|
|
199
|
+
ret.push('Index: ' + fileName);
|
|
200
|
+
ret.push('===================================================================');
|
|
201
|
+
ret.push('--- ' + fileName + (typeof oldHeader === 'undefined' ? '' : '\t' + oldHeader));
|
|
202
|
+
ret.push('+++ ' + fileName + (typeof newHeader === 'undefined' ? '' : '\t' + newHeader));
|
|
203
|
+
|
|
204
|
+
var diff = LineDiff.diff(oldStr, newStr);
|
|
205
|
+
if (!diff[diff.length-1].value) {
|
|
206
|
+
diff.pop(); // Remove trailing newline add
|
|
207
|
+
}
|
|
208
|
+
diff.push({value: '', lines: []}); // Append an empty value to make cleanup easier
|
|
209
|
+
|
|
210
|
+
function contextLines(lines) {
|
|
211
|
+
return lines.map(function(entry) { return ' ' + entry; });
|
|
212
|
+
}
|
|
213
|
+
function eofNL(curRange, i, current) {
|
|
214
|
+
var last = diff[diff.length-2],
|
|
215
|
+
isLast = i === diff.length-2,
|
|
216
|
+
isLastOfType = i === diff.length-3 && (current.added !== last.added || current.removed !== last.removed);
|
|
217
|
+
|
|
218
|
+
// Figure out if this is the last line for the given file and missing NL
|
|
219
|
+
if (!/\n$/.test(current.value) && (isLast || isLastOfType)) {
|
|
220
|
+
curRange.push('\');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var oldRangeStart = 0, newRangeStart = 0, curRange = [],
|
|
225
|
+
oldLine = 1, newLine = 1;
|
|
226
|
+
for (var i = 0; i < diff.length; i++) {
|
|
227
|
+
var current = diff[i],
|
|
228
|
+
lines = current.lines || current.value.replace(/\n$/, '').split('\n');
|
|
229
|
+
current.lines = lines;
|
|
230
|
+
|
|
231
|
+
if (current.added || current.removed) {
|
|
232
|
+
if (!oldRangeStart) {
|
|
233
|
+
var prev = diff[i-1];
|
|
234
|
+
oldRangeStart = oldLine;
|
|
235
|
+
newRangeStart = newLine;
|
|
236
|
+
|
|
237
|
+
if (prev) {
|
|
238
|
+
curRange = contextLines(prev.lines.slice(-4));
|
|
239
|
+
oldRangeStart -= curRange.length;
|
|
240
|
+
newRangeStart -= curRange.length;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
curRange.push.apply(curRange, lines.map(function(entry) { return (current.added?'+':'-') + entry; }));
|
|
244
|
+
eofNL(curRange, i, current);
|
|
245
|
+
|
|
246
|
+
if (current.added) {
|
|
247
|
+
newLine += lines.length;
|
|
248
|
+
} else {
|
|
249
|
+
oldLine += lines.length;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
if (oldRangeStart) {
|
|
253
|
+
// Close out any changes that have been output (or join overlapping)
|
|
254
|
+
if (lines.length <= 8 && i < diff.length-2) {
|
|
255
|
+
// Overlapping
|
|
256
|
+
curRange.push.apply(curRange, contextLines(lines));
|
|
257
|
+
} else {
|
|
258
|
+
// end the range and output
|
|
259
|
+
var contextSize = Math.min(lines.length, 4);
|
|
260
|
+
ret.push(
|
|
261
|
+
'@@ -' + oldRangeStart + ',' + (oldLine-oldRangeStart+contextSize)
|
|
262
|
+
+ ' +' + newRangeStart + ',' + (newLine-newRangeStart+contextSize)
|
|
263
|
+
+ ' @@');
|
|
264
|
+
ret.push.apply(ret, curRange);
|
|
265
|
+
ret.push.apply(ret, contextLines(lines.slice(0, contextSize)));
|
|
266
|
+
if (lines.length <= 4) {
|
|
267
|
+
eofNL(ret, i, current);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
oldRangeStart = 0; newRangeStart = 0; curRange = [];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
oldLine += lines.length;
|
|
274
|
+
newLine += lines.length;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return ret.join('\n') + '\n';
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
applyPatch: function(oldStr, uniDiff) {
|
|
282
|
+
var diffstr = uniDiff.split('\n');
|
|
283
|
+
var diff = [];
|
|
284
|
+
var remEOFNL = false,
|
|
285
|
+
addEOFNL = false;
|
|
286
|
+
|
|
287
|
+
for (var i = (diffstr[0][0]==='I'?4:0); i < diffstr.length; i++) {
|
|
288
|
+
if(diffstr[i][0] === '@') {
|
|
289
|
+
var meh = diffstr[i].split(/@@ -(\d+),(\d+) \+(\d+),(\d+) @@/);
|
|
290
|
+
diff.unshift({
|
|
291
|
+
start:meh[3],
|
|
292
|
+
oldlength:meh[2],
|
|
293
|
+
oldlines:[],
|
|
294
|
+
newlength:meh[4],
|
|
295
|
+
newlines:[]
|
|
296
|
+
});
|
|
297
|
+
} else if(diffstr[i][0] === '+') {
|
|
298
|
+
diff[0].newlines.push(diffstr[i].substr(1));
|
|
299
|
+
} else if(diffstr[i][0] === '-') {
|
|
300
|
+
diff[0].oldlines.push(diffstr[i].substr(1));
|
|
301
|
+
} else if(diffstr[i][0] === ' ') {
|
|
302
|
+
diff[0].newlines.push(diffstr[i].substr(1));
|
|
303
|
+
diff[0].oldlines.push(diffstr[i].substr(1));
|
|
304
|
+
} else if(diffstr[i][0] === '\\') {
|
|
305
|
+
if (diffstr[i-1][0] === '+') {
|
|
306
|
+
remEOFNL = true;
|
|
307
|
+
} else if(diffstr[i-1][0] === '-') {
|
|
308
|
+
addEOFNL = true;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
var str = oldStr.split('\n');
|
|
314
|
+
for (var i = diff.length - 1; i >= 0; i--) {
|
|
315
|
+
var d = diff[i];
|
|
316
|
+
for (var j = 0; j < d.oldlength; j++) {
|
|
317
|
+
if(str[d.start-1+j] !== d.oldlines[j]) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
Array.prototype.splice.apply(str,[d.start-1,+d.oldlength].concat(d.newlines));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (remEOFNL) {
|
|
325
|
+
while (!str[str.length-1]) {
|
|
326
|
+
str.pop();
|
|
327
|
+
}
|
|
328
|
+
} else if (addEOFNL) {
|
|
329
|
+
str.push('');
|
|
330
|
+
}
|
|
331
|
+
return str.join('\n');
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
convertChangesToXML: function(changes){
|
|
335
|
+
var ret = [];
|
|
336
|
+
for ( var i = 0; i < changes.length; i++) {
|
|
337
|
+
var change = changes[i];
|
|
338
|
+
if (change.added) {
|
|
339
|
+
ret.push('<ins>');
|
|
340
|
+
} else if (change.removed) {
|
|
341
|
+
ret.push('<del>');
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
ret.push(escapeHTML(change.value));
|
|
345
|
+
|
|
346
|
+
if (change.added) {
|
|
347
|
+
ret.push('</ins>');
|
|
348
|
+
} else if (change.removed) {
|
|
349
|
+
ret.push('</del>');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return ret.join('');
|
|
353
|
+
},
|
|
354
|
+
|
|
355
|
+
// See: http://code.google.com/p/google-diff-match-patch/wiki/API
|
|
356
|
+
convertChangesToDMP: function(changes){
|
|
357
|
+
var ret = [], change;
|
|
358
|
+
for ( var i = 0; i < changes.length; i++) {
|
|
359
|
+
change = changes[i];
|
|
360
|
+
ret.push([(change.added ? 1 : change.removed ? -1 : 0), change.value]);
|
|
361
|
+
}
|
|
362
|
+
return ret;
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
})();
|
|
366
|
+
|
|
367
|
+
if (typeof module !== 'undefined') {
|
|
368
|
+
module.exports = JsDiff;
|
|
369
|
+
}
|
package/lib/hook.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Runnable = require('./runnable');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('./utils').inherits;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Expose `Hook`.
|
|
@@ -26,10 +26,7 @@ function Hook(title, fn) {
|
|
|
26
26
|
/**
|
|
27
27
|
* Inherit from `Runnable.prototype`.
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
|
-
Hook.prototype = create(Runnable.prototype, {
|
|
31
|
-
constructor: Hook
|
|
32
|
-
});
|
|
29
|
+
inherits(Hook, Runnable);
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
32
|
* Get or set the test `err`.
|
package/lib/mocha.js
CHANGED
|
@@ -85,7 +85,7 @@ function Mocha(options) {
|
|
|
85
85
|
this.ui(options.ui);
|
|
86
86
|
this.bail(options.bail);
|
|
87
87
|
this.reporter(options.reporter, options.reporterOptions);
|
|
88
|
-
if (options.timeout
|
|
88
|
+
if (typeof options.timeout !== 'undefined' && options.timeout !== null) {
|
|
89
89
|
this.timeout(options.timeout);
|
|
90
90
|
}
|
|
91
91
|
this.useColors(options.useColors);
|
package/lib/reporters/base.js
CHANGED
|
@@ -169,7 +169,14 @@ exports.list = function(failures) {
|
|
|
169
169
|
// msg
|
|
170
170
|
var msg;
|
|
171
171
|
var err = test.err;
|
|
172
|
-
var message
|
|
172
|
+
var message;
|
|
173
|
+
if (err.message) {
|
|
174
|
+
message = err.message;
|
|
175
|
+
} else if (typeof err.inspect === 'function') {
|
|
176
|
+
message = err.inspect() + '';
|
|
177
|
+
} else {
|
|
178
|
+
message = '';
|
|
179
|
+
}
|
|
173
180
|
var stack = err.stack || message;
|
|
174
181
|
var index = stack.indexOf(message);
|
|
175
182
|
var actual = err.actual;
|
|
@@ -401,7 +408,7 @@ function unifiedDiff(err, escape) {
|
|
|
401
408
|
return indent + line;
|
|
402
409
|
}
|
|
403
410
|
function notBlank(line) {
|
|
404
|
-
return line
|
|
411
|
+
return typeof line !== 'undefined' && line !== null;
|
|
405
412
|
}
|
|
406
413
|
var msg = diff.createPatch('string', err.actual, err.expected);
|
|
407
414
|
var lines = msg.split('\n').splice(4);
|
package/lib/reporters/dot.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
var color = Base.color;
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -63,7 +63,4 @@ function Dot(runner) {
|
|
|
63
63
|
/**
|
|
64
64
|
* Inherit from `Base.prototype`.
|
|
65
65
|
*/
|
|
66
|
-
|
|
67
|
-
Dot.prototype = create(Base.prototype, {
|
|
68
|
-
constructor: Dot
|
|
69
|
-
});
|
|
66
|
+
inherits(Dot, Base);
|
package/lib/reporters/landing.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
var cursor = Base.cursor;
|
|
8
8
|
var color = Base.color;
|
|
9
9
|
|
|
@@ -89,7 +89,4 @@ function Landing(runner) {
|
|
|
89
89
|
/**
|
|
90
90
|
* Inherit from `Base.prototype`.
|
|
91
91
|
*/
|
|
92
|
-
|
|
93
|
-
Landing.prototype = create(Base.prototype, {
|
|
94
|
-
constructor: Landing
|
|
95
|
-
});
|
|
92
|
+
inherits(Landing, Base);
|
package/lib/reporters/list.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
var color = Base.color;
|
|
8
8
|
var cursor = Base.cursor;
|
|
9
9
|
|
|
@@ -58,7 +58,4 @@ function List(runner) {
|
|
|
58
58
|
/**
|
|
59
59
|
* Inherit from `Base.prototype`.
|
|
60
60
|
*/
|
|
61
|
-
|
|
62
|
-
List.prototype = create(Base.prototype, {
|
|
63
|
-
constructor: List
|
|
64
|
-
});
|
|
61
|
+
inherits(List, Base);
|
package/lib/reporters/min.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Expose `Min`.
|
|
@@ -33,7 +33,4 @@ function Min(runner) {
|
|
|
33
33
|
/**
|
|
34
34
|
* Inherit from `Base.prototype`.
|
|
35
35
|
*/
|
|
36
|
-
|
|
37
|
-
Min.prototype = create(Base.prototype, {
|
|
38
|
-
constructor: Min
|
|
39
|
-
});
|
|
36
|
+
inherits(Min, Base);
|
package/lib/reporters/nyan.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Expose `Dot`.
|
|
@@ -62,10 +62,7 @@ function NyanCat(runner) {
|
|
|
62
62
|
/**
|
|
63
63
|
* Inherit from `Base.prototype`.
|
|
64
64
|
*/
|
|
65
|
-
|
|
66
|
-
NyanCat.prototype = create(Base.prototype, {
|
|
67
|
-
constructor: NyanCat
|
|
68
|
-
});
|
|
65
|
+
inherits(NyanCat, Base);
|
|
69
66
|
|
|
70
67
|
/**
|
|
71
68
|
* Draw the nyan cat
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
var Base = require('./base');
|
|
6
|
-
var
|
|
6
|
+
var inherits = require('../utils').inherits;
|
|
7
7
|
var color = Base.color;
|
|
8
8
|
var cursor = Base.cursor;
|
|
9
9
|
|
|
@@ -86,7 +86,4 @@ function Progress(runner, options) {
|
|
|
86
86
|
/**
|
|
87
87
|
* Inherit from `Base.prototype`.
|
|
88
88
|
*/
|
|
89
|
-
|
|
90
|
-
Progress.prototype = create(Base.prototype, {
|
|
91
|
-
constructor: Progress
|
|
92
|
-
});
|
|
89
|
+
inherits(Progress, Base);
|