r104843 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104842‎ | r104843 | r104844 >
Date:10:58, 1 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Add a parser test whitelist for manually-checked tests, and an option to print
JSON-serialized parser output for failing tests, which can then be added to
the whitelist if appropriate.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/parserTests-whitelist.js (added) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests-whitelist.js
@@ -0,0 +1,13 @@
 2+/* A map of test titles and their manually verified output. If the parser
 3+ * output matches the expected output listed here, the test can be marked as
 4+ * passing in parserTests.js. */
 5+
 6+testWhiteList = {};
 7+
 8+// The order of li/b is swapped in this test, but the resulting formatting is
 9+// identical
 10+testWhiteList['Italics and bold'] = "<ul><li> plain</li><li> plain<i>italic</i>plain</li><li> plain<i>italic</i>plain<i>italic</i>plain</li><li> plain<b>bold</b>plain</li><li> plain<b>bold</b>plain<b>bold</b>plain</li><li> plain<i>italic</i>plain<b>bold</b>plain</li><li> plain<b>bold</b>plain<i>italic</i>plain</li><li> plain<i>italic<b>bold-italic</b>italic</i>plain</li><li> plain<b>bold<i>bold-italic</i>bold</b>plain</li><li> plain<i><b>bold-italic</b>italic</i>plain</li><li> plain<i><b>bold-italic</b></i><b>bold</b>plain</li><li> plain<i>italic<b>bold-italic</b></i>plain</li><li> plain<b>bold<i>bold-italic</i></b>plain</li><li> plain l'<i>italic</i>plain</li><li> plain l'<b>bold</b> plain</li></ul>";
 11+
 12+if (typeof module == "object") {
 13+ module.exports.testWhiteList = testWhiteList;
 14+}
Property changes on: trunk/extensions/VisualEditor/tests/parser/parserTests-whitelist.js
___________________________________________________________________
Added: svn:eol-style
115 + native
Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -47,6 +47,11 @@
4848 default: false,
4949 boolean: true,
5050 },
 51+ 'jsonout': {
 52+ description: 'Print out a JSON serialization (default false) of parser output.',
 53+ default: false,
 54+ boolean: true,
 55+ },
5156 }
5257 ).check( function(argv) {
5358 if( argv.filter === true ) {
@@ -98,6 +103,9 @@
99104
100105
101106 // Our code...
 107+
 108+var testWhiteList = require('./parserTests-whitelist.js').testWhiteList;
 109+
102110 _import(pj('parser', 'mediawiki.parser.peg.js'), ['PegParser']);
103111 _import(pj('parser', 'mediawiki.parser.environment.js'), ['MWParserEnvironment']);
104112 _import(pj('parser', 'ext.cite.taghook.ref.js'), ['MWRefTagHook']);
@@ -226,6 +234,7 @@
227235 }
228236
229237 var passedTests = 0,
 238+ passedTestsManual = 0,
230239 failParseTests = 0,
231240 failTreeTests = 0,
232241 failOutputTests = 0;
@@ -295,6 +304,14 @@
296305 var normalizedOut = normalizeOut(out);
297306 var normalizedExpected = normalizeHTML(item.result);
298307 if ( normalizedOut !== normalizedExpected ) {
 308+ if (item.title in testWhiteList &&
 309+ normalizeOut(testWhiteList[item.title]) === normalizedOut) {
 310+ if( !argv.quiet ) {
 311+ console.log( 'PASSED (whiteList)'.green + ': ' + item.title.yellow );
 312+ }
 313+ passedTestsManual++;
 314+ return;
 315+ }
299316 printTitle( argv.quick );
300317 failOutputTests++;
301318
@@ -335,7 +352,12 @@
336353
337354
338355 console.log( colored_diff );
 356+
 357+ if(argv.jsonout) {
 358+ console.log("JSON of parser output:");
 359+ console.log(JSON.stringify(out));
339360 }
 361+ }
340362 } else {
341363 passedTests++;
342364 if( !argv.quiet ) {
@@ -414,15 +436,18 @@
415437
416438 if( failTotalTests !== 0 ) {
417439 console.log( ColorizeCount( passedTests , 'green' ) + " passed");
 440+console.log( ColorizeCount( passedTestsManual , 'green' ) + " passed from whitelist");
418441 console.log( ColorizeCount( failParseTests , 'red' ) + " parse failures");
419442 console.log( ColorizeCount( failTreeTests , 'red' ) + " tree build failures");
420443 console.log( ColorizeCount( failOutputTests, 'red' ) + " output differences");
421444 console.log( "\n" );
422 -console.log( ColorizeCount( failTotalTests , 'red' ) + " total failures");
 445+console.log( ColorizeCount( passedTests + passedTestsManual , 'green' ) +
 446+ ' total passed tests, ' +
 447+ ColorizeCount( failTotalTests , 'red' ) + " total failures");
423448
424449 } else {
425450 if( test_filter !== null ) {
426 - console.log( "Passed " + passedTests + " of " + passedTests + " tests matching " + test_filter + "... " + "ALL TESTS PASSED!".green );
 451+ console.log( "Passed " + passedTests + passedTestsManual + " of " + passedTests + " tests matching " + test_filter + "... " + "ALL TESTS PASSED!".green );
427452 } else {
428453 // Should not happen if it does: Champagne!
429454 console.log( "Passed " + passedTests + " of " + passedTests + " tests... " + "ALL TESTS PASSED!".green );

Status & tagging log