From 9a63ae34829929fd496e4a0e291188cbde71b3ad Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 13 Apr 2024 17:38:41 +0000 Subject: [PATCH] Merge pull request #1661 from hydephp/fix-extra-newline-being-written-for-failing-build-tasks Fix extra newline being written for failing build tasks https://github.com/hydephp/develop/commit/27d01d46a6cf5fa2bc358f3d701fe45a668708b2 --- src/Framework/Features/BuildTasks/BuildTask.php | 8 ++++---- tests/Unit/BuildTaskUnitTest.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Framework/Features/BuildTasks/BuildTask.php b/src/Framework/Features/BuildTasks/BuildTask.php index 76a50aa3..72b491ae 100644 --- a/src/Framework/Features/BuildTasks/BuildTask.php +++ b/src/Framework/Features/BuildTasks/BuildTask.php @@ -50,11 +50,11 @@ public function run(?OutputStyle $output = null): int $this->printFinishMessage(); } catch (Throwable $exception) { if ($exception instanceof BuildTaskSkippedException) { - $this->writeln('Skipped'); - $this->writeln(" > {$exception->getMessage()}"); + $this->write("Skipped\n"); + $this->write(" > {$exception->getMessage()}"); } else { - $this->writeln('Failed'); - $this->writeln("{$exception->getMessage()}"); + $this->write("Failed\n"); + $this->write("{$exception->getMessage()}"); } $this->exitCode = $exception->getCode(); diff --git a/tests/Unit/BuildTaskUnitTest.php b/tests/Unit/BuildTaskUnitTest.php index 1a0d540c..4b484cf2 100644 --- a/tests/Unit/BuildTaskUnitTest.php +++ b/tests/Unit/BuildTaskUnitTest.php @@ -193,7 +193,7 @@ public function testTaskSkipping() }); $this->assertSame(0, $task->property('exitCode')); - $this->assertSame('Skipped', $task->buffer[1]); + $this->assertSame('Skipped', trim($task->buffer[1])); $this->assertSame(' > Task was skipped', $task->buffer[2]); } @@ -206,7 +206,7 @@ public function testTaskSkippingWithCustomMessage() }); $this->assertSame(0, $task->property('exitCode')); - $this->assertSame('Skipped', $task->buffer[1]); + $this->assertSame('Skipped', trim($task->buffer[1])); $this->assertSame(' > Custom reason', $task->buffer[2]); } @@ -221,7 +221,7 @@ public function testExceptionHandling() $task->run(); $this->assertSame(123, $task->property('exitCode')); - $this->assertSame('Failed', $task->buffer[1]); + $this->assertSame('Failed', trim($task->buffer[1])); $this->assertSame('Test exception', $task->buffer[2]); } }