mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 00:25:04 +00:00
Merge branch 'stable' into master
# Conflicts: # composer.lock # resources/vanilla # src/entity/Living.php # src/pocketmine/Player.php # src/pocketmine/VersionInfo.php # src/pocketmine/block/Potato.php # src/pocketmine/block/Sugarcane.php # src/pocketmine/entity/Entity.php # src/pocketmine/item/Item.php # src/pocketmine/level/format/Chunk.php # src/pocketmine/level/format/io/leveldb/LevelDB.php # src/world/generator/GeneratorRegisterTask.php # tests/phpstan/configs/check-explicit-mixed-baseline.neon # tests/phpstan/configs/l7-baseline.neon # tests/phpstan/configs/l8-baseline.neon # tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMainLoggerTest.php # tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMemoryLeakTest.php # tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskPublishProgressRaceTest.php
This commit is contained in:
@ -38,14 +38,14 @@ class Main extends PluginBase implements Listener{
|
||||
/** @var int */
|
||||
protected $currentTestNumber = 0;
|
||||
|
||||
public function onEnable(){
|
||||
public function onEnable() : void{
|
||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||
$this->getScheduler()->scheduleRepeatingTask(new CheckTestCompletionTask($this), 10);
|
||||
|
||||
$this->waitingTests = [];
|
||||
}
|
||||
|
||||
public function onServerCommand(CommandEvent $event){
|
||||
public function onServerCommand(CommandEvent $event) : void{
|
||||
//The CI will send this command as a failsafe to prevent the build from hanging if the tester plugin failed to
|
||||
//run. However, if the plugin loaded successfully we don't want to allow this to stop the server as there may
|
||||
//be asynchronous tests running. Instead we cancel this and stop the server of our own accord once all tests
|
||||
@ -55,10 +55,7 @@ class Main extends PluginBase implements Listener{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Test|null
|
||||
*/
|
||||
public function getCurrentTest(){
|
||||
public function getCurrentTest() : ?Test{
|
||||
return $this->currentTest;
|
||||
}
|
||||
|
||||
@ -73,7 +70,7 @@ class Main extends PluginBase implements Listener{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function onTestCompleted(Test $test){
|
||||
public function onTestCompleted(Test $test) : void{
|
||||
$message = "Finished test #" . $this->currentTestNumber . " (" . $test->getName() . "): ";
|
||||
switch($test->getResult()){
|
||||
case Test::RESULT_OK:
|
||||
@ -99,7 +96,7 @@ class Main extends PluginBase implements Listener{
|
||||
$this->currentTest = null;
|
||||
}
|
||||
|
||||
public function onAllTestsCompleted(){
|
||||
public function onAllTestsCompleted() : void{
|
||||
$this->getLogger()->notice("All tests finished, stopping the server");
|
||||
$this->getServer()->shutdown();
|
||||
}
|
||||
|
@ -29,9 +29,13 @@ abstract class Test{
|
||||
const RESULT_FAILED = 1;
|
||||
const RESULT_ERROR = 2;
|
||||
|
||||
/** @var Main */
|
||||
private $plugin;
|
||||
/** @var int */
|
||||
private $result = Test::RESULT_WAITING;
|
||||
/** @var int */
|
||||
private $startTime;
|
||||
/** @var int */
|
||||
private $timeout = 60; //seconds
|
||||
|
||||
public function __construct(Main $plugin){
|
||||
@ -42,7 +46,7 @@ abstract class Test{
|
||||
return $this->plugin;
|
||||
}
|
||||
|
||||
final public function start(){
|
||||
final public function start() : void{
|
||||
$this->startTime = time();
|
||||
try{
|
||||
$this->run();
|
||||
@ -55,11 +59,11 @@ abstract class Test{
|
||||
}
|
||||
}
|
||||
|
||||
public function tick(){
|
||||
public function tick() : void{
|
||||
|
||||
}
|
||||
|
||||
abstract public function run();
|
||||
abstract public function run() : void;
|
||||
|
||||
public function isFinished() : bool{
|
||||
return $this->result !== Test::RESULT_WAITING;
|
||||
@ -69,7 +73,7 @@ abstract class Test{
|
||||
return !$this->isFinished() and time() - $this->timeout > $this->startTime;
|
||||
}
|
||||
|
||||
protected function setTimeout(int $timeout){
|
||||
protected function setTimeout(int $timeout) : void{
|
||||
$this->timeout = $timeout;
|
||||
}
|
||||
|
||||
@ -77,7 +81,7 @@ abstract class Test{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
public function setResult(int $result){
|
||||
public function setResult(int $result) : void{
|
||||
$this->result = $result;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user