mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-12 16:35:10 +00:00
18d122b60d
This reverts commit 62e1fb0b5f
.
Reason for revert: caused several errors:
* unnamespaced HooksTest collides with core’s class of the same name
* Scribunto_LuaError renamed without class alias despite being used in Wikibase
Bug: T314464
Change-Id: I8b151327236bf86945e59823fba155497e4b3fc6
39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
|
|
|
use MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxEngine;
|
|
use MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxInterpreter;
|
|
|
|
if ( !wfIsCLI() ) {
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/../LuaCommon/LuaInterpreterTest.php';
|
|
|
|
/**
|
|
* @group Lua
|
|
* @group LuaSandbox
|
|
* @covers \MediaWiki\Extension\Scribunto\Engines\LuaSandbox\LuaSandboxInterpreter
|
|
*/
|
|
class LuaSandboxInterpreterTest extends Scribunto_LuaInterpreterTest {
|
|
/** @var array */
|
|
public $stdOpts = [
|
|
'memoryLimit' => 50000000,
|
|
'cpuLimit' => 30,
|
|
];
|
|
|
|
protected function newInterpreter( $opts = [] ) {
|
|
$opts += $this->stdOpts;
|
|
$engine = new LuaSandboxEngine( $this->stdOpts );
|
|
return new LuaSandboxInterpreter( $engine, $opts );
|
|
}
|
|
|
|
public function testGetMemoryUsage() {
|
|
$interpreter = $this->newInterpreter();
|
|
$chunk = $interpreter->loadString( 's = string.rep("x", 1000000)', 'mem' );
|
|
$interpreter->callFunction( $chunk );
|
|
$mem = $interpreter->getPeakMemoryUsage();
|
|
$this->assertGreaterThan( 1000000, $mem, 'memory usage' );
|
|
$this->assertLessThan( 10000000, $mem, 'memory usage' );
|
|
}
|
|
}
|