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 |
1 | 15 | + native |
Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js |
— | — | @@ -47,6 +47,11 @@ |
48 | 48 | default: false, |
49 | 49 | boolean: true, |
50 | 50 | }, |
| 51 | + 'jsonout': { |
| 52 | + description: 'Print out a JSON serialization (default false) of parser output.', |
| 53 | + default: false, |
| 54 | + boolean: true, |
| 55 | + }, |
51 | 56 | } |
52 | 57 | ).check( function(argv) { |
53 | 58 | if( argv.filter === true ) { |
— | — | @@ -98,6 +103,9 @@ |
99 | 104 | |
100 | 105 | |
101 | 106 | // Our code... |
| 107 | + |
| 108 | +var testWhiteList = require('./parserTests-whitelist.js').testWhiteList; |
| 109 | + |
102 | 110 | _import(pj('parser', 'mediawiki.parser.peg.js'), ['PegParser']); |
103 | 111 | _import(pj('parser', 'mediawiki.parser.environment.js'), ['MWParserEnvironment']); |
104 | 112 | _import(pj('parser', 'ext.cite.taghook.ref.js'), ['MWRefTagHook']); |
— | — | @@ -226,6 +234,7 @@ |
227 | 235 | } |
228 | 236 | |
229 | 237 | var passedTests = 0, |
| 238 | + passedTestsManual = 0, |
230 | 239 | failParseTests = 0, |
231 | 240 | failTreeTests = 0, |
232 | 241 | failOutputTests = 0; |
— | — | @@ -295,6 +304,14 @@ |
296 | 305 | var normalizedOut = normalizeOut(out); |
297 | 306 | var normalizedExpected = normalizeHTML(item.result); |
298 | 307 | 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 | + } |
299 | 316 | printTitle( argv.quick ); |
300 | 317 | failOutputTests++; |
301 | 318 | |
— | — | @@ -335,7 +352,12 @@ |
336 | 353 | |
337 | 354 | |
338 | 355 | console.log( colored_diff ); |
| 356 | + |
| 357 | + if(argv.jsonout) { |
| 358 | + console.log("JSON of parser output:"); |
| 359 | + console.log(JSON.stringify(out)); |
339 | 360 | } |
| 361 | + } |
340 | 362 | } else { |
341 | 363 | passedTests++; |
342 | 364 | if( !argv.quiet ) { |
— | — | @@ -414,15 +436,18 @@ |
415 | 437 | |
416 | 438 | if( failTotalTests !== 0 ) { |
417 | 439 | console.log( ColorizeCount( passedTests , 'green' ) + " passed"); |
| 440 | +console.log( ColorizeCount( passedTestsManual , 'green' ) + " passed from whitelist"); |
418 | 441 | console.log( ColorizeCount( failParseTests , 'red' ) + " parse failures"); |
419 | 442 | console.log( ColorizeCount( failTreeTests , 'red' ) + " tree build failures"); |
420 | 443 | console.log( ColorizeCount( failOutputTests, 'red' ) + " output differences"); |
421 | 444 | 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"); |
423 | 448 | |
424 | 449 | } else { |
425 | 450 | 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 ); |
427 | 452 | } else { |
428 | 453 | // Should not happen if it does: Champagne! |
429 | 454 | console.log( "Passed " + passedTests + " of " + passedTests + " tests... " + "ALL TESTS PASSED!".green ); |