mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 07:15:38 +08:00
Add extension configure tests
This commit is contained in:
@@ -6,6 +6,7 @@ namespace SPC\builder;
|
||||
|
||||
use SPC\exception\ExceptionHandler;
|
||||
use SPC\exception\FileSystemException;
|
||||
use SPC\exception\InterruptException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\store\Config;
|
||||
@@ -407,6 +408,13 @@ abstract class BuilderBase
|
||||
}
|
||||
logger()->debug('Running additional patch script: ' . $patch);
|
||||
require $patch;
|
||||
} catch (InterruptException $e) {
|
||||
if ($e->getCode() === 0) {
|
||||
logger()->notice('Patch script ' . $patch . ' interrupted' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
|
||||
} else {
|
||||
logger()->error('Patch script ' . $patch . ' interrupted with error code [' . $e->getCode() . ']' . ($e->getMessage() ? (': ' . $e->getMessage()) : '.'));
|
||||
}
|
||||
exit($e->getCode());
|
||||
} catch (\Throwable $e) {
|
||||
logger()->critical('Patch script ' . $patch . ' failed to run.');
|
||||
if ($this->getOption('debug')) {
|
||||
@@ -414,6 +422,7 @@ abstract class BuilderBase
|
||||
} else {
|
||||
logger()->critical('Please check with --debug option to see more details.');
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
src/SPC/exception/InterruptException.php
Normal file
7
src/SPC/exception/InterruptException.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\exception;
|
||||
|
||||
class InterruptException extends \Exception {}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SPC\builder\BuilderBase;
|
||||
use SPC\builder\BuilderProvider;
|
||||
use SPC\exception\InterruptException;
|
||||
use SPC\exception\RuntimeException;
|
||||
use SPC\exception\WrongUsageException;
|
||||
use SPC\util\UnixShell;
|
||||
@@ -125,6 +126,11 @@ function patch_point(): string
|
||||
return BuilderProvider::getBuilder()->getPatchPoint();
|
||||
}
|
||||
|
||||
function patch_point_interrupt(int $retcode, string $msg = ''): InterruptException
|
||||
{
|
||||
return new InterruptException(message: $msg, code: $retcode);
|
||||
}
|
||||
|
||||
// ------- function f_* part -------
|
||||
// f_ means standard function wrapper
|
||||
|
||||
|
||||
Reference in New Issue
Block a user