Skip to content

Commit

Permalink
Merge pull request #1749 from hydephp/skipped-build-task-exit-codes
Browse files Browse the repository at this point in the history
[2x] Use a non-zero exit code 3 when skipping build tasks
  • Loading branch information
caendesilva authored Jun 28, 2024
2 parents aebf524 + 7a3ad7f commit 8407347
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This serves two purposes:
- Minor: `Includes::path()` and `Includes::get()` methods now normalizes paths to be basenames to match the behaviour of the other include methods in https://github.com/hydephp/develop/pull/1738. This means that nested directories are no longer supported, as you should use a data collection for that.
- Minor: The `processing_time_ms` attribute in the `sitemap.xml` file has now been removed in https://github.com/hydephp/develop/pull/1744
- Improved the sitemap data generation to be smarter and more dynamic in https://github.com/hydephp/develop/pull/1744
- Skipped build tasks will now exit with an exit code of 3 instead of 0 in https://github.com/hydephp/develop/pull/1749
- The `hasFeature` method on the Hyde facade and HydeKernel now only accepts a Feature enum value instead of a string for its parameter.
- Changed how the documentation search is generated, to be an `InMemoryPage` instead of a post-build task.
- Media asset files are now copied using the new build task instead of the deprecated `BuildService::transferMediaAssets()` method.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class BuildTaskSkippedException extends RuntimeException
{
public function __construct(string $message = 'Task was skipped', int $code = 0)
public function __construct(string $message = 'Task was skipped', int $code = 3)
{
parent::__construct($message, $code);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testSitemapIsNotGeneratedWhenConditionsAreNotMet()
->expectsOutputToContain('Generating sitemap...')
->expectsOutputToContain('Skipped')
->expectsOutput(' > Cannot generate sitemap without a valid base URL')
->assertExitCode(0);
->assertExitCode(3);

$this->assertFileDoesNotExist(Hyde::path('_site/sitemap.xml'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testDefaultExceptionCode()
{
$exception = new BuildTaskSkippedException();

$this->assertSame(0, $exception->getCode());
$this->assertSame(3, $exception->getCode());
}

public function testCustomExceptionCode()
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/tests/Unit/BuildTaskUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function testTaskSkipping()
})->run();
});

$this->assertSame(0, $task->property('exitCode'));
$this->assertSame(3, $task->property('exitCode'));
$this->assertSame('<bg=yellow>Skipped</>', trim($task->buffer[1]));
$this->assertSame('<fg=gray> > Task was skipped</>', $task->buffer[2]);
}
Expand All @@ -205,7 +205,7 @@ public function testTaskSkippingWithCustomMessage()
})->run();
});

$this->assertSame(0, $task->property('exitCode'));
$this->assertSame(3, $task->property('exitCode'));
$this->assertSame('<bg=yellow>Skipped</>', trim($task->buffer[1]));
$this->assertSame('<fg=gray> > Custom reason</>', $task->buffer[2]);
}
Expand Down

0 comments on commit 8407347

Please sign in to comment.