Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | var fs = require('fs'), |
18 | 18 | path = require('path'), |
19 | 19 | jsDiff = require('diff'), |
| 20 | + colors = require('colors'), |
20 | 21 | HTML5 = require('html5').HTML5; |
21 | 22 | |
22 | 23 | // @fixme wrap more or this setup in a common module |
— | — | @@ -197,9 +198,9 @@ |
198 | 199 | |
199 | 200 | function printTitle() { |
200 | 201 | console.log('====================================================='); |
201 | | - console.log('FAILED: ' + item.title); |
| 202 | + console.log('FAILED'.red + ': ' + item.title.yellow); |
202 | 203 | console.log(item.comments.join('\n')); |
203 | | - console.log("INPUT:"); |
| 204 | + console.log("INPUT".cyan + ":"); |
204 | 205 | console.log(item.input + "\n"); |
205 | 206 | } |
206 | 207 | |
— | — | @@ -242,28 +243,42 @@ |
243 | 244 | if ( normalizedOut !== normalizedExpected ) { |
244 | 245 | printTitle(); |
245 | 246 | failOutputTests++; |
246 | | - console.log('RAW EXPECTED:'); |
| 247 | + console.log('RAW EXPECTED'.cyan + ':'); |
247 | 248 | console.log(item.result + "\n"); |
248 | 249 | |
249 | | - console.log('RAW RENDERED:'); |
| 250 | + console.log('RAW RENDERED'.cyan + ':'); |
250 | 251 | console.log(formatHTML(out) + "\n"); |
251 | 252 | |
252 | 253 | var a = formatHTML(normalizedExpected); |
253 | 254 | |
254 | | - console.log('NORMALIZED EXPECTED:'); |
| 255 | + console.log('NORMALIZED EXPECTED'.magenta + ':'); |
255 | 256 | console.log(a + "\n"); |
256 | 257 | |
257 | 258 | var b = formatHTML(normalizedOut); |
258 | 259 | |
259 | | - console.log('NORMALIZED RENDERED:') |
| 260 | + console.log('NORMALIZED RENDERED'.magenta + ':') |
260 | 261 | console.log(formatHTML(normalizeOut(out)) + "\n"); |
261 | 262 | var patch = jsDiff.createPatch('wikitext.txt', a, b, 'before', 'after'); |
262 | 263 | |
263 | | - console.log('DIFF:'); |
264 | | - console.log(patch.replace(/^[^\n]*\n[^\n]*\n[^\n]*\n[^\n]*\n/, '')); |
| 264 | + console.log('DIFF'.cyan +': '); |
| 265 | + |
| 266 | + var colored_diff = patch.split( '\n' ).map( function(line) { |
| 267 | + // Add some colors to diff output |
| 268 | + switch( line.charAt(0) ) { |
| 269 | + case '-': |
| 270 | + return line.red; |
| 271 | + case '+': |
| 272 | + return line.blue; |
| 273 | + default: |
| 274 | + return line; |
| 275 | + } |
| 276 | + }).join( "\n" ); |
| 277 | + //patch.replace(/^[^\n]*\n[^\n]*\n[^\n]*\n[^\n]*\n/, '') |
| 278 | + |
| 279 | + console.log( colored_diff ); |
265 | 280 | } else { |
266 | 281 | passedTests++; |
267 | | - console.log( 'PASSED: ' + item.title ); |
| 282 | + console.log( 'PASSED'.green + ': ' + item.title.yellow ); |
268 | 283 | } |
269 | 284 | } |
270 | 285 | }); |
Index: trunk/extensions/VisualEditor/tests/parser/README |
— | — | @@ -3,6 +3,7 @@ |
4 | 4 | Batch-testing tools loading the parsing code into node.js, and going through a MediaWiki XML export dump to run round-trip tests over it. Currently not much will succeed as there's bad handling of newlines. ;) |
5 | 5 | |
6 | 6 | Need npm modules: |
| 7 | +* colors |
7 | 8 | * html5 |
8 | 9 | * jquery |
9 | 10 | * jsdom |