MarkTraceur has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52331


Change subject: Honor language=xx option in parserTests.txt
......................................................................

Honor language=xx option in parserTests.txt

This patch implements the language=xx option in parserTests for
wt2html.  This may expose some failures in l10n.  In particular, the
tests are now run in the 'en' prefix by default (as thay are in the
PHP parser tests), and the linktrail and linkprefix for 'en' become
significant.  A bug in the WikitextSerializer is also
exposed in the "Simple category in language variants" test case, which
doesn't properly normalize the category link name when the locale is
set.

This is an unrevert commit with an additional error-handling mechanism.
I've made this commit primarily so I could rebase it on top of another one.

Change-Id: I11a992c157e6d4068846f80a0d9ee1a7aca815d7
---
M js/lib/mediawiki.ApiRequest.js
M js/tests/parserTests.js
2 files changed, 30 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/31/52331/1

diff --git a/js/lib/mediawiki.ApiRequest.js b/js/lib/mediawiki.ApiRequest.js
index 22c168a..dff687a 100644
--- a/js/lib/mediawiki.ApiRequest.js
+++ b/js/lib/mediawiki.ApiRequest.js
@@ -411,6 +411,11 @@
                        siprop: siprops.join( '|' )
                };
 
+       if ( !uri ) {
+               this.requestCB( new Error( 'There was no base URI for the API 
we tried to use.' ) );
+               return;
+       }
+
        var url = uri + '?' +
                qs.stringify( apiargs );
 
diff --git a/js/tests/parserTests.js b/js/tests/parserTests.js
index f872c21..32d7c06 100644
--- a/js/tests/parserTests.js
+++ b/js/tests/parserTests.js
@@ -518,7 +518,7 @@
        cb( null, content, changelist );
 };
 
-ParserTests.prototype.convertWt2Html = function( mode, wikitext, processHtmlCB 
) {
+ParserTests.prototype.convertWt2Html = function( mode, prefix, variant, 
wikitext, processHtmlCB ) {
        try {
                this.parserPipeline.once( 'document', function ( doc ) {
                        // processHtmlCB can be asynchronous, so deep-clone
@@ -531,7 +531,26 @@
                processHtmlCB( e );
        }
        this.env.page.src = wikitext;
-       this.parserPipeline.process( wikitext );
+       this.env.switchToConfig( prefix, function( err ) {
+               if ( err ) {
+                       processHtmlCB( err );
+               } else {
+                       // TODO: set language variant
+                       // adjust config to match that used for PHP tests
+                       // see core/tests/parser/parserTest.inc:setupGlobals() 
for
+                       // full set of config normalizations done.
+                       this.env.conf.wiki.server = 'http://example.org';
+                       this.env.conf.wiki.wgScriptPath = '/';
+                       this.env.conf.wiki.script = '/index.php';
+                       this.env.conf.wiki.articlePath = '/wiki/$1';
+                       // this has been updated in the live wikis, but the 
parser tests
+                       // expect the old value (as set in 
parserTest.inc:setupDatabase())
+                       this.env.conf.wiki.interwikiMap.meatball.url =
+                               'http://www.usemod.com/cgi-bin/mb.pl?$1';
+                       // convert this wikitext!
+                       this.parserPipeline.process( wikitext );
+               }
+       }.bind(this));
 };
 
 /**
@@ -556,6 +575,8 @@
        }
 
        item.time = {};
+       var prefix = (item.options || {}).language || 'en';
+       var variant = (item.options || {}).variant;
 
        // Build a list of tasks for this test that will be passed to 
async.waterfall
        var finishHandler = function ( err, res ) {
@@ -604,7 +625,7 @@
        // First conversion stage
        if ( startsAtWikitext ) {
                if ( item.cachedHTML === null ) {
-                       testTasks.push( this.convertWt2Html.bind( this, mode, 
item.input ) );
+                       testTasks.push( this.convertWt2Html.bind( this, mode, 
prefix, variant, item.input ) );
                } else {
                        testTasks.push( function ( cb ) {
                                cb( null, item.cachedHTML.cloneNode( true ) );
@@ -645,7 +666,7 @@
        if ( mode === 'wt2wt' || mode === 'selser' ) {
                testTasks.push( this.convertHtml2Wt.bind( this, options, mode, 
item ) );
        } else if ( mode === 'html2html' ) {
-               testTasks.push( this.convertWt2Html.bind( this, mode ) );
+               testTasks.push( this.convertWt2Html.bind( this, mode, prefix, 
variant ) );
        }
 
        // Processing stage

-- 
To view, visit https://gerrit.wikimedia.org/r/52331
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I11a992c157e6d4068846f80a0d9ee1a7aca815d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>

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

Reply via email to