Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197986
Change subject: Tweaks to marcoil's patch.
......................................................................
Tweaks to marcoil's patch.
Change-Id: I6fbda95bdc466ecf34ad99fa92cfc52f8c83bb55
---
M tests/parserTests.js
1 file changed, 16 insertions(+), 23 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/86/197986/1
diff --git a/tests/parserTests.js b/tests/parserTests.js
index 7a6159c..d913bb9 100755
--- a/tests/parserTests.js
+++ b/tests/parserTests.js
@@ -1746,14 +1746,13 @@
var tasks = [],
self = this;
for ( var i = 0; i < modes.length; i++ ) {
- if ( modes[i] === 'selser' && options.numchanges &&
options.selser !== 'noauto' ) {
- var newitem;
+ if ( modes[i] === 'selser' ) {
// Prepend manual changes, if present, but not if
'selser' isn't
// in the explicit modes option.
if (item.options.parsoid &&
item.options.parsoid.changes) {
tasks.push( function ( cb ) {
- newitem = Util.clone(item);
+ var newitem = Util.clone(item);
// Mutating the item here is necessary
to output 'manual' in
// the test's title and to
differentiate it for blacklist.
// It can only get here in two cases:
@@ -1779,11 +1778,16 @@
continue;
}
- item.selserChangeTrees = new Array( options.numchanges
);
+ if ( !options.numchanges ) {
+ // No automatically-generated changes?
+ continue;
+ }
+ var sharedItem = Util.clone( item );
+ sharedItem.selserChangeTrees = new Array(
options.numchanges );
// Prepend a selser test that appends a comment to the
root node
tasks.push( function ( cb ) {
- newitem = Util.clone(item);
+ var newitem = Util.clone(sharedItem);
newitem.changetree = 5;
self.processTest( newitem, options, 'selser',
function() {
setImmediate(cb);
@@ -1791,7 +1795,7 @@
});
var done = false;
- for ( var j = 0; j < item.selserChangeTrees.length; j++
) {
+ for ( var j = 0; j <
sharedItem.selserChangeTrees.length; j++ ) {
// we create the function in the loop but are
careful to
// bind loop variables i and j at function
creation time
/* jshint loopfunc: true */
@@ -1799,22 +1803,22 @@
if (done) {
setImmediate( cb );
} else {
- newitem = Util.clone( item );
+ var newitem = Util.clone(
sharedItem );
// Make sure we aren't reusing
the one from manual changes
console.assert(newitem.changetree === undefined);
newitem.seed = changesIndex +
'';
this.processTest( newitem,
options, modes[modeIndex], function () {
- if (
this.isDuplicateChangeTree( item.selserChangeTrees, newitem.changes ) ) {
+ if (
this.isDuplicateChangeTree( sharedItem.selserChangeTrees, newitem.changes ) ) {
// Once we get
a duplicate change tree, we can no longer
// generate and
run new tests. So, be done now!
done = true;
} else {
-
item.selserChangeTrees[changesIndex] = newitem.changes;
+
sharedItem.selserChangeTrees[changesIndex] = newitem.changes;
}
// Push the caches
forward!
- item.cachedBODY =
newitem.cachedBODY;
-
item.cachedNormalizedHTML = newitem.cachedNormalizedHTML;
+ sharedItem.cachedBODY =
newitem.cachedBODY;
+
sharedItem.cachedNormalizedHTML = newitem.cachedNormalizedHTML;
setImmediate( cb );
}.bind( this ) );
@@ -1822,18 +1826,7 @@
}.bind( this, i, j ) );
}
} else {
- // When manual changes were requested, exclude tests
that don't have
- // any.
- if (modes[i] === 'selser' && options.selser ===
'noauto' &&
- !(item.options.parsoid &&
item.options.parsoid.changes)) {
- continue;
- } else if (modes[i] === 'selser' && options.selser ===
'noauto') {
- // If it does have manual changes, we need to
create a new item
- // for its selser test.
- tasks.push(this.processTest.bind(this,
Util.clone(item), options, modes[i]));
- } else {
- tasks.push( this.processTest.bind( this, item,
options, modes[i] ) );
- }
+ tasks.push( this.processTest.bind( this, item, options,
modes[i] ) );
}
}
return tasks;
--
To view, visit https://gerrit.wikimedia.org/r/197986
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6fbda95bdc466ecf34ad99fa92cfc52f8c83bb55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits