refactor: unified kernal logic clean up

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-07-27 08:54:37 -04:00
parent 65c1b5fb75
commit eb99eb5a2e
10 changed files with 197 additions and 130 deletions
+38
View File
@@ -65,6 +65,44 @@ final class KernelTest extends TestCase
self::assertTrue($scope->terminated());
}
#[Test]
#[TestDox('Runner returns execution results and terminates')]
public function runs(): void
{
$processor = new RecordingProcessor();
[$kernel] = $this->kernel($processor);
$result = $kernel->executionRunner()->execute(
ExecutionDescriptor::cli(),
static fn(): string => 'complete',
);
self::assertSame('complete', $result);
self::assertSame(1, $processor->processed);
}
#[Test]
#[TestDox('Runner terminates before rethrowing execution failures')]
public function rethrows(): void
{
[$kernel] = $this->kernel();
try {
$kernel->executionRunner()->execute(
ExecutionDescriptor::cli(),
static fn() => throw new \RuntimeException('Execution failed.'),
);
self::fail('Expected execution to fail.');
} catch (\RuntimeException $error) {
self::assertSame('Execution failed.', $error->getMessage());
}
$scope = $kernel->beginExecution(ExecutionDescriptor::cli());
$kernel->terminateExecution($scope, ExecutionOutcome::success());
self::assertTrue($scope->terminated());
}
#[Test]
#[TestDox('Only one execution scope can be active')]
public function rejectsConcurrentScopes(): void