From: Antoine Musso Date: Mon, 11 Sep 2017 10:58:13 +0000 (+0200) Subject: tests: ensure parserTestRunner restores $wgParser X-Git-Tag: 1.31.0-rc.0~2157 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=875fe1693c44b14da05639968f124d6050d27975;p=lhc%2Fweb%2Fwiklou.git tests: ensure parserTestRunner restores $wgParser ParserTestRunner::addArticle() set a dummy $wgParser to ease test running. However if doEditContent() fails, it would abort and never restore $wgParser. Make sure the restoration is done even on exception. I caught that one while running parser tests with Scribunto and Cite. My setup lacked a luastandalone which causes Scribunto to throw an exception. When the Cite tests are run, the MessageCache parser ended up using $wgParser = ParserTestMockParser; Change-Id: I33a0a5c1f40f197405d40b7925cc043342e6757e --- diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 298a3c10c5..5fe2177d11 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1604,12 +1604,15 @@ class ParserTestRunner { // get a reference to the mock object. MessageCache::singleton()->getParser(); $restore = $this->executeSetupSnippets( [ 'wgParser' => new ParserTestMockParser ] ); - $status = $page->doEditContent( - ContentHandler::makeContent( $text, $title ), - '', - EDIT_NEW | EDIT_INTERNAL - ); - $restore(); + try { + $status = $page->doEditContent( + ContentHandler::makeContent( $text, $title ), + '', + EDIT_NEW | EDIT_INTERNAL + ); + } finally { + $restore(); + } if ( !$status->isOK() ) { throw new MWException( $status->getWikiText( false, false, 'en' ) );