mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-30 19:14:22 +00:00
Fix unit test engine↔parser assignment
In the unit tests, the engine is given a parser, but the parser is not being associated back with the engine. So in some cases, that could lead to *another*, default engine being created for certain operations. Fix that. Change-Id: I79995c2635d9e470931b84dc1854dae26772bbe3
This commit is contained in:
parent
201bf237b3
commit
981ea4c39f
|
@ -65,8 +65,6 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
||||||
$suite->setName( $className );
|
$suite->setName( $className );
|
||||||
|
|
||||||
$class = new ReflectionClass( $className );
|
$class = new ReflectionClass( $className );
|
||||||
$parser = new Parser;
|
|
||||||
$parser->startExternalParse( Title::newMainPage(), new ParserOptions, Parser::OT_HTML, true );
|
|
||||||
|
|
||||||
foreach ( self::$engineConfigurations as $engineName => $opts ) {
|
foreach ( self::$engineConfigurations as $engineName => $opts ) {
|
||||||
if ( $group !== null && $group !== $engineName ) {
|
if ( $group !== null && $group !== $engineName ) {
|
||||||
|
@ -74,10 +72,13 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$parser = new Parser;
|
||||||
|
$parser->startExternalParse( Title::newMainPage(), new ParserOptions, Parser::OT_HTML, true );
|
||||||
$engineClass = "Scribunto_{$engineName}Engine";
|
$engineClass = "Scribunto_{$engineName}Engine";
|
||||||
$engine = new $engineClass(
|
$engine = new $engineClass(
|
||||||
self::$engineConfigurations[$engineName] + array( 'parser' => $parser )
|
self::$engineConfigurations[$engineName] + array( 'parser' => $parser )
|
||||||
);
|
);
|
||||||
|
$parser->scribunto_engine = $engine;
|
||||||
$engine->setTitle( $parser->getTitle() );
|
$engine->setTitle( $parser->getTitle() );
|
||||||
$engine->getInterpreter();
|
$engine->getInterpreter();
|
||||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||||
|
@ -163,6 +164,7 @@ abstract class Scribunto_LuaEngineTestBase extends MediaWikiTestCase {
|
||||||
$this->engine = new $class(
|
$this->engine = new $class(
|
||||||
self::$engineConfigurations[$this->engineName] + array( 'parser' => $parser )
|
self::$engineConfigurations[$this->engineName] + array( 'parser' => $parser )
|
||||||
);
|
);
|
||||||
|
$parser->scribunto_engine = $this->engine;
|
||||||
$this->engine->setTitle( $parser->getTitle() );
|
$this->engine->setTitle( $parser->getTitle() );
|
||||||
}
|
}
|
||||||
return $this->engine;
|
return $this->engine;
|
||||||
|
|
|
@ -16,33 +16,34 @@ class Scribunto_LuaEnvironmentComparisonTest extends MediaWikiTestCase {
|
||||||
|
|
||||||
protected $engines = array();
|
protected $engines = array();
|
||||||
|
|
||||||
function setUp() {
|
function makeEngine( $class, $opts ) {
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$parser = new Parser;
|
$parser = new Parser;
|
||||||
$options = new ParserOptions;
|
$options = new ParserOptions;
|
||||||
$options->setTemplateCallback( array( $this, 'templateCallback' ) );
|
$options->setTemplateCallback( array( $this, 'templateCallback' ) );
|
||||||
$parser->startExternalParse( Title::newMainPage(), $options, Parser::OT_HTML, true );
|
$parser->startExternalParse( Title::newMainPage(), $options, Parser::OT_HTML, true );
|
||||||
|
$engine = new $class ( array( 'parser' => $parser ) + $opts );
|
||||||
try {
|
$parser->scribunto_engine = $engine;
|
||||||
$engine = new Scribunto_LuaSandboxEngine(
|
|
||||||
array( 'parser' => $parser ) + $this->sandboxOpts
|
|
||||||
);
|
|
||||||
$engine->setTitle( $parser->getTitle() );
|
$engine->setTitle( $parser->getTitle() );
|
||||||
$engine->getInterpreter();
|
$engine->getInterpreter();
|
||||||
$this->engines['LuaSandbox'] = $engine;
|
return $engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->engines['LuaSandbox'] = $this->makeEngine(
|
||||||
|
'Scribunto_LuaSandboxEngine', $this->sandboxOpts
|
||||||
|
);
|
||||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||||
$this->markTestSkipped( "LuaSandbox interpreter not available" );
|
$this->markTestSkipped( "LuaSandbox interpreter not available" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$engine = new Scribunto_LuaStandaloneEngine(
|
$this->engines['LuaStandalone'] = $this->makeEngine(
|
||||||
array( 'parser' => $parser ) + $this->standaloneOpts
|
'Scribunto_LuaStandaloneEngine', $this->standaloneOpts
|
||||||
);
|
);
|
||||||
$engine->setTitle( $parser->getTitle() );
|
|
||||||
$engine->getInterpreter();
|
|
||||||
$this->engines['LuaStandalone'] = $engine;
|
|
||||||
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
} catch ( Scribunto_LuaInterpreterNotFoundError $e ) {
|
||||||
$this->markTestSkipped( "LuaStandalone interpreter not available" );
|
$this->markTestSkipped( "LuaStandalone interpreter not available" );
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue