Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2x] Use a non-zero exit code 3 when skipping build tasks #1749

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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