Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86806
Change subject: Added --changetree and --dump dom:post-changes options to
parserTests
......................................................................
Added --changetree and --dump dom:post-changes options to parserTests
* I often want to run a selser test with a specific changetree applied
to it. Finally, I scratched that itch. Not sure why it took me so
long.
* Also added an additional dom dump option to dump the DOM post-changes
for debugging purposes.
Change-Id: I4ab7a5ad9480a4aacdb3ad35a722f9a31dfc78f1
---
M js/tests/parserTests.js
1 file changed, 26 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/06/86806/1
diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index c66436d..9ef01ef 100755
--- a/js/tests/parserTests.js
+++ b/js/tests/parserTests.js
@@ -184,6 +184,11 @@
'default': false,
'boolean': true
},
+ 'changetree': {
+ description: 'Changes to apply to parsed HTML to
generate new HTML to be serialized (useful with selser)',
+ 'default': null,
+ 'boolean': false
+ },
'use_source': {
description: 'Use original source in wt2wt tests',
'boolean': true,
@@ -567,6 +572,14 @@
applyChangesInternal(content, item.changes);
}
+ if (this.env.conf.parsoid.dumpFlags.indexOf("dom:post-changes") !== -1)
{
+ console.warn("-------------------------");
+ console.warn("Change tree: " + JSON.stringify(item.changes));
+ console.warn("-------------------------");
+ console.warn("DOM with changes applied: " + content.outerHTML);
+ console.warn("-------------------------");
+ }
+
if (cb) {
cb( null, content );
}
@@ -866,7 +879,13 @@
// Generate and make changes for the selser test mode
if ( mode === 'selser' ) {
- testTasks.push( this.generateChanges.bind( this, options, item
) );
+ if ( options.changetree ) {
+ testTasks.push( function(content, cb) {
+ cb( null, content,
JSON.parse(options.changetree) );
+ } );
+ } else {
+ testTasks.push( this.generateChanges.bind( this,
options, item ) );
+ }
testTasks.push( this.applyChanges.bind( this, item ) );
// Save the modified DOM so we can re-test it later
@@ -1313,6 +1332,11 @@
ParserTests.prototype.main = function ( options ) {
if ( options.help ) {
optimist.showHelp();
+ console.error("Additional dump options specific to parserTests
script:")
+ console.error("* dom:post-changes : Dumps DOM after applying
selser changetree\n");
+ console.error("Examples");
+ console.error("$ node parserTests --selser --filter '...'
--dump dom:post-changes");
+ console.error("$ node parserTests --selser --filter '...'
--changetree '...' --dump dom:post-changes\n");
process.exit( 0 );
}
Util.setColorFlags( options );
@@ -1491,7 +1515,7 @@
ParserTests.prototype.buildTasks = function ( item, modes, options ) {
var tasks = [];
for ( var i = 0; i < modes.length; i++ ) {
- if ( modes[i] === 'selser' && options.numchanges ) {
+ if ( modes[i] === 'selser' && options.numchanges &&
!options.changetree ) {
item.selserChangeTrees = new Array( options.numchanges
);
var done = false;
--
To view, visit https://gerrit.wikimedia.org/r/86806
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ab7a5ad9480a4aacdb3ad35a722f9a31dfc78f1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits