diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 180659f5..f37ff3a2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -18,8 +18,8 @@ jobs: stability: [prefer-lowest, prefer-stable] include: - laravel: 10.* - testbench: 8.* - carbon: ^2.63 + testbench: ^8.18 + carbon: ^2.67 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -42,10 +42,18 @@ jobs: - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction + composer update --${{ matrix.stability }} --no-interaction - name: List Installed Dependencies run: composer show -D - - name: Execute tests + - name: Show pest version + run: vendor/bin/pest --version + + - name: Execute tests on Linux + if: matrix.os == 'ubuntu-latest' + run: Xvfb :99 & DISPLAY=:99 vendor/bin/pest + + - name: Execute tests on Windows + if: matrix.os == 'windows-latest' run: vendor/bin/pest diff --git a/composer.json b/composer.json index b633d341..d2b363b6 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "nunomaduro/collision": "^7.9", "nunomaduro/larastan": "^2.0.1", "orchestra/testbench": "^8.18", - "pestphp/pest": "^2.0", + "pestphp/pest": "^2.7", "pestphp/pest-plugin-arch": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "phpstan/extension-installer": "^1.1", diff --git a/src/Commands/DevelopCommand.php b/src/Commands/DevelopCommand.php index faa9f712..586780dc 100644 --- a/src/Commands/DevelopCommand.php +++ b/src/Commands/DevelopCommand.php @@ -39,7 +39,7 @@ public function handle(): void $this->installIcon(); - $this->runDeveloper(installer: $this->option('installer'), skip_queue: $this->option('no-queue')); + $this->runDeveloper(installer: $this->option('installer'), skip_queue: $this->option('no-queue'), withoutInteraction: $this->option('no-interaction')); } /** diff --git a/src/Traits/Developer.php b/src/Traits/Developer.php index 73e15037..e7266735 100644 --- a/src/Traits/Developer.php +++ b/src/Traits/Developer.php @@ -8,11 +8,11 @@ trait Developer { use ExecuteCommand; - protected function runDeveloper(string $installer, bool $skip_queue): void + protected function runDeveloper(string $installer, bool $skip_queue, bool $withoutInteraction = false): void { [$installer, $command] = $this->getInstallerAndCommand(installer: $installer, type: 'dev'); note("Running the dev script with {$installer}..."); - $this->executeCommand(command: $command, type: 'serve', skip_queue: $skip_queue); + $this->executeCommand(command: $command, skip_queue: $skip_queue, type: 'serve', withoutInteraction: $withoutInteraction); } } diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php index 59b6f95a..6155a817 100644 --- a/tests/ExampleTest.php +++ b/tests/ExampleTest.php @@ -1,30 +1,40 @@ setTty(true)->start(function ($type, $line) { - echo $line; + $output = ''; + + $process = remote('native:serve --no-dependencies --no-interaction'); + $process->start(function ($type, $line) use (&$output) { + $output .= $line; }); try { - retry(12, function () { + retry(20, function () use ($output) { // Wait until port 8100 is open dump('Waiting for port 8100 to open...'); + $fp = @fsockopen('localhost', 8100, $errno, $errstr, 1); if ($fp === false) { - throw new Exception('Port 8100 is not open yet'); + throw new Exception(sprintf( + 'Port 8100 is not open yet. Output: "%s"', + $output, + )); } }, 5000); - } catch (Exception $e) { - Process::run('pkill -9 -P '.$process->getPid()); - throw $e; + } finally { + $process->stop(); } - Process::run('pkill -9 -P '.$process->getPid()); - - expect(true)->toBeTrue(); + try { + expect($output)->toContain('Running the dev script with npm'); + } catch (ExpectationFailedException) { + throw new ExpectationFailedException(sprintf( + '"%s" does not match the expected output.', + $output, + )); + } }); diff --git a/tests/TestCase.php b/tests/TestCase.php index d942d91c..d54c57da 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -16,6 +16,6 @@ protected function setUp(): void { parent::setUp(); - Artisan::call('native:install', ['--force' => true]); + Artisan::call('native:install', ['--force' => true, '--no-interaction' => true]); } }