r104432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104431‎ | r104432 | r104433 >
Date:14:53, 28 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Provide a summary of failures.
Modified paths:
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -146,12 +146,13 @@
147147 .innerHTML;
148148 } catch(e) {
149149 console.log("normalizeHTML failed:" + e);
 150+ console.trace();
150151 return source;
151152 }
152153
153154 }
154155
155 -// Specialized normalization of the parser output, mostly to ignore a few
 156+// Specialized normalization of the wiki parser output, mostly to ignore a few
156157 // known-ok differences.
157158 function normalizeOut ( out ) {
158159 // TODO: Do not strip newlines in pre and nowiki blocks!
@@ -159,11 +160,15 @@
160161 }
161162
162163 function formatHTML ( source ) {
163 - // Quick hack to insert newlines before block level start tags!
164 - return source.replace(/(?!^)<((dd|dt|li|p|table|tr|td|tbody|dl|ol|ul)[^>]*)>/g,
 164+ // Quick hack to insert newlines before some block level start tags
 165+ return source.replace(/(?!^)<((div|dd|dt|li|p|table|tr|td|tbody|dl|ol|ul)[^>]*)>/g,
165166 '\n<$1>');
166167 }
167168
 169+var passedTests = 0,
 170+ failParseTests = 0,
 171+ failTreeTests = 0,
 172+ failOutputTests = 0;
168173
169174 function processTest(item) {
170175 var tokenizer = new FauxHTML5.Tokenizer();
@@ -191,6 +196,7 @@
192197 parser.parseToTree(item.input + "\n", function(tokens, err) {
193198 if (err) {
194199 printTitle();
 200+ failParseTests++;
195201 console.log('PARSE FAIL', err);
196202 } else {
197203 var environment = new MWParserEnvironment({
@@ -208,9 +214,11 @@
209215
210216 if ( err ) {
211217 printTitle();
 218+ failTreeTests++;
212219 console.log('RENDER FAIL', err);
213220 } else if ( normalizeOut(out) !== normalizeHTML(item.result) ) {
214221 printTitle();
 222+ failOutputTests++;
215223 console.log('RAW EXPECTED:');
216224 console.log(item.result + "\n");
217225
@@ -231,6 +239,7 @@
232240 console.log('DIFF:');
233241 console.log(patch.replace(/^[^\n]*\n[^\n]*\n[^\n]*\n[^\n]*\n/, ''));
234242 } else {
 243+ passedTests++;
235244 console.log( 'PASS: ' + item.title );
236245 }
237246 }
@@ -270,4 +279,14 @@
271280 }
272281 }
273282 });
 283+
 284+console.log( "==========================================================");
 285+console.log( "SUMMARY: ");
 286+console.log( passedTests + " passed");
 287+console.log( failParseTests + " parse failures");
 288+console.log( failTreeTests + " tree build failures");
 289+console.log( failOutputTests + " output differences");
 290+console.log( "\n" + (failParseTests + failTreeTests + failOutputTests) + " total failures");
 291+console.log( "==========================================================");
 292+
274293 })();

Status & tagging log