function setUp()
 {
     parent::setUp();
     $parser = new Parser();
     $options = new ParserOptions();
     $options->setTemplateCallback(array($this, 'templateCallback'));
     $parser->startExternalParse(Title::newMainPage(), $options, Parser::OT_HTML, true);
     try {
         $engine = new Scribunto_LuaSandboxEngine(array('parser' => $parser) + $this->sandboxOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaSandbox'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaSandbox interpreter not available");
         return;
     }
     try {
         $engine = new Scribunto_LuaStandaloneEngine(array('parser' => $parser) + $this->standaloneOpts);
         $engine->setTitle($parser->getTitle());
         $engine->getInterpreter();
         $this->engines['LuaStandalone'] = $engine;
     } catch (Scribunto_LuaInterpreterNotFoundError $e) {
         $this->markTestSkipped("LuaStandalone interpreter not available");
         return;
     }
 }
 /**
  * @return mixed
  */
 function getClockTick()
 {
     if (self::$clockTick === null) {
         wfSuppressWarnings();
         self::$clockTick = intval(shell_exec('getconf CLK_TCK'));
         wfRestoreWarnings();
         if (!self::$clockTick) {
             self::$clockTick = 100;
         }
     }
     return self::$clockTick;
 }
 /**
  * @throws ScribuntoException
  */
 protected function checkStatus()
 {
     $this->checkValid();
     $status = proc_get_status($this->proc);
     if (!$status['running']) {
         wfDebug(__METHOD__ . ": not running\n");
         proc_close($this->proc);
         $this->proc = false;
         if ($status['signaled']) {
             $this->exitError = $this->engine->newException('scribunto-luastandalone-signal', array('args' => array($status['termsig'])));
         } elseif (defined('SIGXCPU') && $status['exitcode'] == 128 + SIGXCPU) {
             $this->exitError = $this->engine->newException('scribunto-common-timeout');
         } else {
             $this->exitError = $this->engine->newException('scribunto-luastandalone-exited', array('args' => array($status['exitcode'])));
         }
         throw $this->exitError;
     }
 }
 /**
  * @throws ScribuntoException
  */
 protected function handleIOError()
 {
     $this->checkValid();
     proc_terminate($this->proc);
     $wstatus = proc_close($this->proc);
     $signaled = pcntl_wifsignaled($wstatus);
     $termsig = pcntl_wtermsig($wstatus);
     $exitcode = pcntl_wexitstatus($wstatus);
     $this->proc = false;
     if ($signaled) {
         if (defined('SIGXCPU') && $termsig == SIGXCPU) {
             $this->exitError = $this->engine->newException('scribunto-common-timeout');
         } else {
             $this->exitError = $this->engine->newException('scribunto-luastandalone-signal', array('args' => array($termsig)));
         }
     } else {
         $this->exitError = $this->engine->newException('scribunto-luastandalone-exited', array('args' => array($exitcode)));
     }
     throw $this->exitError;
 }