-
Notifications
You must be signed in to change notification settings - Fork 112
fix: Prevent install command from breaking when /tests
doesn't exist
#93
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
Conversation
Simplifies the determineTestEnforcement method by removing the minimum test file check and always prompting the user to decide if AI should create tests. Updates collectInstallationPreferences to match the new method signature.
I just noticed that the current flow is set to never ask and have |
@sagalbot $testsPath = base_path('tests');
$hasMinimumTests = false;
if (is_dir($testsPath)) {
$hasMinimumTests = Finder::create()
->in($testsPath)
->files()
->name('*.php')
->count() > 6;
} What do you think about this suggestion? |
This would be my preference too for right now, checking if We added the |
Updated the determineTestEnforcement method to automatically check for a minimum number of tests before prompting the user. Introduced a constant for the minimum test count and integrated Symfony Process to list and count tests.
Replaces the use of collect and explode with Str helper methods for trimming and splitting the process output when counting tests.
Replaces hardcoded 'php' with PHP_BINARY and sets the working directory to base_path() when running the test listing process. This improves compatibility with different PHP environments and ensures the process runs in the correct directory.
/tests
doesn't exist/tests
doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashleyhindle I have tested this locally.
LGTM 🚀
Thanks @sagalbot, you're the best 🫶 |
Currently, on
v1.0.9
,php artisan boost:install
will fail for any project that doesn't contain atests
directory at the root of the project.The installer looks for tests within the directory to determine if the user should be prompted about AI writing tests. The strategy here makes sense - remove an install step if no tests are found, but the current implementation will fail for many projects.
I think the simplest possible solution here is to just ask the user. Yes, it's one extra step, but it puts control in the hands of the user. If you're installing into a fresh Laravel project, the arbitrary 6 test threshold means you won't be asked about AI test guidelines.
If you do want to use the presence of tests as a way to determine if this question should be asked, you could call
phpunit --list-tests
and check if the output is >=6 lines. That should work for jest and phpunit regardless of test ___location.Changes
/tests
(fixes install failure)Resolves #45