jenkins-bot has submitted this change and it was merged.

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, 28 insertions(+), 2 deletions(-)

Approvals:
  Arlolra: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index c66436d..d3a18dd 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,16 @@
                applyChangesInternal(content, item.changes);
        }
 
+       if (this.env.conf.parsoid.dumpFlags &&
+               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 +881,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 +1334,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 +1517,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: merged
Gerrit-Change-Id: I4ab7a5ad9480a4aacdb3ad35a722f9a31dfc78f1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to