Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -381,13 +381,49 @@ |
382 | 382 | } |
383 | 383 | }); |
384 | 384 | |
| 385 | +/** |
| 386 | + * Colorize given number if <> 0 |
| 387 | + * |
| 388 | + * @param count Integer: a number to colorize |
| 389 | + * @param color String: 'green' or 'red' |
| 390 | + */ |
| 391 | +function ColorizeCount( count, color ) { |
| 392 | + if( count === 0 ) { |
| 393 | + return count; |
| 394 | + } |
| 395 | + |
| 396 | + // We need a string to use colors methods |
| 397 | + count = count.toString(); |
| 398 | + // FIXME there must be a wait to call a method by its name |
| 399 | + switch( color ) { |
| 400 | + case 'green': return count.green; |
| 401 | + case 'red': return count.red; |
| 402 | + |
| 403 | + default: return count; |
| 404 | + } |
| 405 | +} |
| 406 | + |
| 407 | +var failTotalTests = (failParseTests + failTreeTests + failOutputTests); |
| 408 | + |
385 | 409 | console.log( "=========================================================="); |
386 | 410 | console.log( "SUMMARY: "); |
387 | | -console.log( passedTests + " passed"); |
388 | | -console.log( failParseTests + " parse failures"); |
389 | | -console.log( failTreeTests + " tree build failures"); |
390 | | -console.log( failOutputTests + " output differences"); |
391 | | -console.log( "\n" + (failParseTests + failTreeTests + failOutputTests) + " total failures"); |
| 411 | + |
| 412 | +if( failTotalTests !== 0 ) { |
| 413 | +console.log( ColorizeCount( passedTests , 'green' ) + " passed"); |
| 414 | +console.log( ColorizeCount( failParseTests , 'red' ) + " parse failures"); |
| 415 | +console.log( ColorizeCount( failTreeTests , 'red' ) + " tree build failures"); |
| 416 | +console.log( ColorizeCount( failOutputTests, 'red' ) + " output differences"); |
| 417 | +console.log( "\n" ); |
| 418 | +console.log( ColorizeCount( failTotalTests , 'red' ) + " total failures"); |
| 419 | + |
| 420 | +} else { |
| 421 | + if( test_filter !== null ) { |
| 422 | + console.log( "Passed " + passedTests + " of " + passedTests + " tests matching " + test_filter + "... " + "ALL TESTS PASSED!".green ); |
| 423 | + } else { |
| 424 | + // Should not happen if it does: Champagne! |
| 425 | + console.log( "Passed " + passedTests + " of " + passedTests + " tests... " + "ALL TESTS PASSED!".green ); |
| 426 | + } |
| 427 | +} |
392 | 428 | console.log( "=========================================================="); |
393 | 429 | |
394 | 430 | })(); |