scratch – Blame information for rev 133
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
75 | office | 1 | /* |
2 | Copyright (c) 2008-2013 Pivotal Labs |
||
3 | |||
4 | Permission is hereby granted, free of charge, to any person obtaining |
||
5 | a copy of this software and associated documentation files (the |
||
6 | "Software"), to deal in the Software without restriction, including |
||
7 | without limitation the rights to use, copy, modify, merge, publish, |
||
8 | distribute, sublicense, and/or sell copies of the Software, and to |
||
9 | permit persons to whom the Software is furnished to do so, subject to |
||
10 | the following conditions: |
||
11 | |||
12 | The above copyright notice and this permission notice shall be |
||
13 | included in all copies or substantial portions of the Software. |
||
14 | |||
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||
17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
||
19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
||
20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
||
21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
22 | */ |
||
23 | function getJasmineRequireObj() { |
||
24 | if (typeof module !== "undefined" && module.exports) { |
||
25 | return exports; |
||
26 | } else { |
||
27 | window.jasmineRequire = window.jasmineRequire || {}; |
||
28 | return window.jasmineRequire; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | getJasmineRequireObj().console = function(jRequire, j$) { |
||
33 | j$.ConsoleReporter = jRequire.ConsoleReporter(); |
||
34 | }; |
||
35 | |||
36 | getJasmineRequireObj().ConsoleReporter = function() { |
||
37 | |||
38 | var noopTimer = { |
||
39 | start: function(){}, |
||
40 | elapsed: function(){ return 0; } |
||
41 | }; |
||
42 | |||
43 | function ConsoleReporter(options) { |
||
44 | var print = options.print, |
||
45 | showColors = options.showColors || false, |
||
46 | onComplete = options.onComplete || function() {}, |
||
47 | timer = options.timer || noopTimer, |
||
48 | specCount, |
||
49 | failureCount, |
||
50 | failedSpecs = [], |
||
51 | pendingCount, |
||
52 | ansi = { |
||
53 | green: '\x1B[32m', |
||
54 | red: '\x1B[31m', |
||
55 | yellow: '\x1B[33m', |
||
56 | none: '\x1B[0m' |
||
57 | }; |
||
58 | |||
59 | this.jasmineStarted = function() { |
||
60 | specCount = 0; |
||
61 | failureCount = 0; |
||
62 | pendingCount = 0; |
||
63 | print("Started"); |
||
64 | printNewline(); |
||
65 | timer.start(); |
||
66 | }; |
||
67 | |||
68 | this.jasmineDone = function() { |
||
69 | printNewline(); |
||
70 | for (var i = 0; i < failedSpecs.length; i++) { |
||
71 | specFailureDetails(failedSpecs[i]); |
||
72 | } |
||
73 | |||
74 | printNewline(); |
||
75 | var specCounts = specCount + " " + plural("spec", specCount) + ", " + |
||
76 | failureCount + " " + plural("failure", failureCount); |
||
77 | |||
78 | if (pendingCount) { |
||
79 | specCounts += ", " + pendingCount + " pending " + plural("spec", pendingCount); |
||
80 | } |
||
81 | |||
82 | print(specCounts); |
||
83 | |||
84 | printNewline(); |
||
85 | var seconds = timer.elapsed() / 1000; |
||
86 | print("Finished in " + seconds + " " + plural("second", seconds)); |
||
87 | |||
88 | printNewline(); |
||
89 | |||
90 | onComplete(failureCount === 0); |
||
91 | }; |
||
92 | |||
93 | this.specDone = function(result) { |
||
94 | specCount++; |
||
95 | |||
96 | if (result.status == "pending") { |
||
97 | pendingCount++; |
||
98 | print(colored("yellow", "*")); |
||
99 | return; |
||
100 | } |
||
101 | |||
102 | if (result.status == "passed") { |
||
103 | print(colored("green", '.')); |
||
104 | return; |
||
105 | } |
||
106 | |||
107 | if (result.status == "failed") { |
||
108 | failureCount++; |
||
109 | failedSpecs.push(result); |
||
110 | print(colored("red", 'F')); |
||
111 | } |
||
112 | }; |
||
113 | |||
114 | return this; |
||
115 | |||
116 | function printNewline() { |
||
117 | print("\n"); |
||
118 | } |
||
119 | |||
120 | function colored(color, str) { |
||
121 | return showColors ? (ansi[color] + str + ansi.none) : str; |
||
122 | } |
||
123 | |||
124 | function plural(str, count) { |
||
125 | return count == 1 ? str : str + "s"; |
||
126 | } |
||
127 | |||
128 | function repeat(thing, times) { |
||
129 | var arr = []; |
||
130 | for (var i = 0; i < times; i++) {> |
||
131 | < times; i++) { arr.push(thing);> |
||
132 | < times; i++) { }> |
||
133 | < times; i++) { return arr;> |
||
134 | < times; i++) { }> |
||
135 | |||
136 | < times; i++) { function indent(str, spaces) {> |
||
137 | < times; i++) { var lines = (str || '').split("\n");> |
||
138 | < times; i++) { var newArr = [];> |
||
139 | < times; i++) { for (var i = 0; i < lines.length; i++) {>> |
||
140 | < times; i++) {< lines.length; i++) { newArr.push(repeat(" ", spaces).join("") + lines[i]);>> |
||
141 | < times; i++) {< lines.length; i++) { }>> |
||
142 | < times; i++) {< lines.length; i++) { return newArr.join("\n");>> |
||
143 | < times; i++) {< lines.length; i++) { }>> |
||
144 | |||
145 | < times; i++) {< lines.length; i++) { function specFailureDetails(result) {>> |
||
146 | < times; i++) {< lines.length; i++) { printNewline();>> |
||
147 | < times; i++) {< lines.length; i++) { print(result.fullName);>> |
||
148 | |||
149 | < times; i++) {< lines.length; i++) { for (var i = 0; i < result.failedExpectations.length; i++) {>>> |
||
150 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { var failedExpectation = result.failedExpectations[i];>>> |
||
151 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { printNewline();>>> |
||
152 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { print(indent(failedExpectation.stack, 2));>>> |
||
153 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { }>>> |
||
154 | |||
155 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { printNewline();>>> |
||
156 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { }>>> |
||
157 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { }>>> |
||
158 | |||
159 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) { return ConsoleReporter;>>> |
||
160 | < times; i++) {< lines.length; i++) {< result.failedExpectations.length; i++) {};>>> |