mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-28 02:00:01 +00:00
aa4d72e3ff
The following continue to be ignored: * Generic.Arrays.DisallowLongArraySyntax.Found, because I'm not sure Scribunto is ready to abandon old version support in master. * MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures, because it's overly strict for its purpose. Squiz.Classes.ValidClassName.NotCamelCaps isn't ignored globally, we just ignore it explicitly every place it's needed. Change-Id: I307668da6ef7b3e23da19b1fd1e08914239b99b3
36 lines
976 B
PHP
36 lines
976 B
PHP
<?php
|
|
|
|
if ( PHP_SAPI !== 'cli' ) {
|
|
exit;
|
|
}
|
|
|
|
require_once __DIR__ . '/../LuaCommon/LuaInterpreterTest.php';
|
|
|
|
/**
|
|
* @group Lua
|
|
* @group LuaSandbox
|
|
*/
|
|
// @codingStandardsIgnoreLine Squiz.Classes.ValidClassName.NotCamelCaps
|
|
class Scribunto_LuaSandboxInterpreterTest extends Scribunto_LuaInterpreterTest {
|
|
public $stdOpts = array(
|
|
'memoryLimit' => 50000000,
|
|
'cpuLimit' => 30,
|
|
);
|
|
|
|
protected function newInterpreter( $opts = array() ) {
|
|
$opts = $opts + $this->stdOpts;
|
|
$engine = new Scribunto_LuaSandboxEngine( $this->stdOpts );
|
|
return new Scribunto_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' );
|
|
}
|
|
}
|
|
|