Marcoil has uploaded a new change for review. https://gerrit.wikimedia.org/r/200208
Change subject: [roundtrip-test] Use API v2 for doubleRoundtripDiff too ...................................................................... [roundtrip-test] Use API v2 for doubleRoundtripDiff too This should fix the differences in semantic/syntactic classification with results when using API v1. Change-Id: I734cca8047044382c09b09fe0513d613f8d983de --- M tests/roundtrip-test.js 1 file changed, 35 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/08/200208/1 diff --git a/tests/roundtrip-test.js b/tests/roundtrip-test.js index 4c8df06..8cc93e8 100755 --- a/tests/roundtrip-test.js +++ b/tests/roundtrip-test.js @@ -294,8 +294,17 @@ return walkDOM(root); }; -var checkIfSignificant = function ( env, offsets, src, body, out, cb, document ) { +var checkIfSignificant = function ( env, offsets, src, body, oldDp, out, cb, err, html, dp ) { + if (err) { + cb(err, null, []); + return; + } + var document = domino.createDocument(html); + // Merge data-parsoid so that HTML nodes can be compared and diff'ed. + DU.applyDataParsoid(body.ownerDocument, oldDp.body); + DU.applyDataParsoid(document, dp.body); + // console.warn("\ndocument:", document) var normalizeWikitext = function ( str ) { @@ -411,23 +420,6 @@ cb( null, env, results ); }; -var doubleRoundtripDiff = function ( env, offsets, src, body, out, cb ) { - if ( offsets.length > 0 ) { - env.setPageSrcInfo( out ); - env.errCB = function ( error ) { - cb( error, env, [] ); - process.exit( 1 ); - }; - - var parserPipeline = env.pipelineFactory.getPipeline('text/x-mediawiki/full'); - parserPipeline.once( 'document', checkIfSignificant.bind( null, env, offsets, src, body, out, cb ) ); - parserPipeline.processToplevelDoc( out ); - - } else { - cb( null, env, [] ); - } -}; - var parsoidPost = function (env, uri, domain, title, text, dp, oldid, recordSizes, profilePrefix, cb) { var data = {}; @@ -503,7 +495,23 @@ } ); }; -var roundTripDiff = function ( env, src, html, out, cb ) { +var doubleRoundtripDiff = function (env, uri, domain, title, offsets, src, body, dp, out, cb) { + if ( offsets.length > 0 ) { + env.setPageSrcInfo( out ); + env.errCB = function ( error ) { + cb( error, env, [] ); + process.exit( 1 ); + }; + + parsoidPost(env, uri, domain, title, out, null, null, false, null, + checkIfSignificant.bind(null, env, offsets, src, body, dp, out, cb)); + + } else { + cb( null, env, [] ); + } +}; + +var roundTripDiff = function ( env, uri, domain, title, src, html, dp, out, cb ) { var diff, offsetPairs; try { @@ -512,7 +520,7 @@ if ( diff.length > 0 ) { var body = domino.createDocument( html ).body; - doubleRoundtripDiff( env, offsetPairs, src, body, out, cb ); + doubleRoundtripDiff( env, uri, domain, title, offsetPairs, src, body, dp, out, cb ); } else { cb( null, env, [] ); } @@ -521,14 +529,14 @@ } }; -var selserRoundTripDiff = function (env, html, out, diffs, cb) { +var selserRoundTripDiff = function (env, uri, domain, title, html, dp, out, diffs, cb) { var selserDiff, offsetPairs, src = env.page.src.replace(/\n(?=\n)/g, '\n '); // Remove the selser trigger comment out = out.replace(/<!--rtSelserEditTestComment-->\n*$/, ''); out = out.replace(/\n(?=\n)/g, '\n '); - roundTripDiff(env, src, html, out, function (err, env, selserDiffs) { + roundTripDiff(env, uri, domain, title, src, html, dp, out, function (err, env, selserDiffs) { if (err) { cb(err, env, diffs); } else { @@ -623,7 +631,9 @@ env.profile.time.total += new Date() - env.profile.time.total_timer; } - selserRoundTripDiff(env, origHTMLBody, wtSelserBody, rtDiffs, cb); + selserRoundTripDiff(env, options.parsoidURL, + domain, page, origHTMLBody, origDp, wtSelserBody, + rtDiffs, cb); }); } }; @@ -636,7 +646,8 @@ parsoidPostShort(htmlBody, htmlDp, src_and_metadata.revision.revid, true, null, function (wtBody) { - roundTripDiff(env, env.page.src, htmlBody, wtBody, + roundTripDiff(env, options.parsoidURL, domain, page, + env.page.src, htmlBody, htmlDp, wtBody, rtSelserTest.bind(null, htmlBody, htmlDp)); }); }); -- To view, visit https://gerrit.wikimedia.org/r/200208 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I734cca8047044382c09b09fe0513d613f8d983de Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Marcoil <marc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits