r104708 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104707‎ | r104708 | r104709 >
Date:17:43, 30 November 2011
Author:hashar
Status:deferred
Tags:
Comment:
colorize numbers in test summary

Also added Brion's ALL TEST PASSED when it makes sense
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -381,13 +381,49 @@
382382 }
383383 });
384384
 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+
385409 console.log( "==========================================================");
386410 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+}
392428 console.log( "==========================================================");
393429
394430 })();

Status & tagging log