|
2 | 2 | var vows = require('vows')
|
3 | 3 | , assert = require('assert')
|
4 | 4 | , os = require('os')
|
| 5 | +, semver = require('semver') |
5 | 6 | , EOL = os.EOL || '\n';
|
6 | 7 |
|
7 | 8 | //used for patternLayout tests.
|
@@ -108,7 +109,7 @@ vows.describe('log4js layouts').addBatch({
|
108 | 109 | });
|
109 | 110 | },
|
110 | 111 | 'should print error the contained error message': function(layoutOutput) {
|
111 |
| - var m = layoutOutput.match(/\{ \[Error: My Unique Error Message\]/); |
| 112 | + var m = layoutOutput.match(/Error: My Unique Error Message/); |
112 | 113 | assert.isArray(m);
|
113 | 114 | },
|
114 | 115 | 'should print error augmented string attributes': function(layoutOutput) {
|
@@ -142,23 +143,34 @@ vows.describe('log4js layouts').addBatch({
|
142 | 143 | assert.equal(layout(event), "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test");
|
143 | 144 | },
|
144 | 145 | 'should output a stacktrace, message if the event has an error attached': function(args) {
|
145 |
| - var layout = args[0], event = args[1], output, lines, |
| 146 | + var i, layout = args[0], event = args[1], output, lines, |
146 | 147 | error = new Error("Some made-up error"),
|
147 | 148 | stack = error.stack.split(/\n/);
|
148 | 149 |
|
149 | 150 | event.data = ['this is a test', error];
|
150 | 151 | output = layout(event);
|
151 | 152 | lines = output.split(/\n/);
|
152 | 153 |
|
153 |
| - assert.equal(lines.length - 1, stack.length); |
154 |
| - assert.equal( |
155 |
| - lines[0], |
156 |
| - "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test [Error: Some made-up error]" |
157 |
| - ); |
158 |
| - |
159 |
| - for (var i = 1; i < stack.length; i++) { |
160 |
| - assert.equal(lines[i+2], stack[i+1]); |
| 154 | + if (semver.satisfies(process.version, '>=6')) { |
| 155 | + assert.equal(lines.length, stack.length); |
| 156 | + assert.equal( |
| 157 | + lines[0], |
| 158 | + "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test Error: Some made-up error" |
| 159 | + ); |
| 160 | + for (i = 1; i < stack.length; i++) { |
| 161 | + assert.equal(lines[i], stack[i]); |
| 162 | + } |
| 163 | + } else { |
| 164 | + assert.equal(lines.length - 1, stack.length); |
| 165 | + assert.equal( |
| 166 | + lines[0], |
| 167 | + "[2010-12-05 14:18:30.045] [DEBUG] tests - this is a test [Error: Some made-up error]" |
| 168 | + ); |
| 169 | + for (i = 1; i < stack.length; i++) { |
| 170 | + assert.equal(lines[i+2], stack[i+1]); |
| 171 | + } |
161 | 172 | }
|
| 173 | + |
162 | 174 | },
|
163 | 175 | 'should output any extra data in the log event as util.inspect strings': function(args) {
|
164 | 176 | var layout = args[0], event = args[1], output, lines;
|
|
0 commit comments