From 0200f90e9a670b7fbf82445827732949f9d769d7 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 15:06:10 +0100 Subject: [PATCH 01/39] Start of work on better TeamCity output --- src/Logging/TeamCity.php | 76 ++++++++++++++++++++++++++++++++++ tests/Features/Expect/json.php | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 14704aab..8033a798 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -139,23 +139,43 @@ final class TeamCity extends DefaultResultPrinter return; } + if (!$this->lastTestFailed) { + $this->writePestTestOutput($test->getName(), 'green', '✓'); + } + if ($test instanceof TestCase) { $this->numAssertions += $test->getNumAssertions(); } elseif ($test instanceof PhptTestCase) { $this->numAssertions++; } + $this->lastTestFailed = false; + $this->printEvent('testFinished', [ self::NAME => $test->getName(), self::DURATION => self::toMilliseconds($time), ]); } + protected function writePestTestOutput(string $message, string $color, string $symbol, callable $suffix = null) + { + $this->writeProgressWithColor("fg-$color, bold", "$symbol "); + $this->writeProgress($message); + + if ($suffix) { + $suffix(); + } + + $this->writeNewLine(); + } + /** * @param Test|Testable $test */ public function addError(Test $test, Throwable $t, float $time): void { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'red', '⨯'); $this->phpunitTeamCity->addError($test, $t, $time); } @@ -169,13 +189,32 @@ final class TeamCity extends DefaultResultPrinter $this->phpunitTeamCity->addWarning($test, $e, $time); } + public function addRiskyTest(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'yellow', '!', function() use ($t) { + $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); + }); + } + public function addFailure(Test $test, AssertionFailedError $e, float $time): void { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'red', '⨯'); $this->phpunitTeamCity->addFailure($test, $e, $time); } protected function writeProgress(string $progress): void { + parent::writeProgress($progress); + } + + public function addSkippedTest(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'yellow', '-', function() use ($t) { + $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); + }); } /** @@ -197,6 +236,43 @@ final class TeamCity extends DefaultResultPrinter $this->write("]\n"); } + protected function countSuccessfulTests(TestResult $result) + { + return $result->count() + - $result->failureCount() + - $result->errorCount() + - $result->skippedCount() + - $result->warningCount(); + } + + protected function printFooter(TestResult $result): void + { + $this->writeProgress('Tests: '); + + $results = [ + 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-yellow'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], + 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-yellow'], + 'passed' => ['count' => $this->countSuccessfulTests($result), 'color' => 'fg-green'], + ]; + + $filteredResults = array_filter($results, function($item) { + return $item['count'] > 0; + }); + + foreach ($filteredResults as $key => $result) { + $this->writeProgressWithColor($result['color'], $result['count'] . " $key"); + + if ($key !== array_reverse(array_keys($filteredResults))[0]) { + $this->write(', '); + } + } + + $this->writeNewLine(); + } + private static function escapeValue(string $text): string { return str_replace( diff --git a/tests/Features/Expect/json.php b/tests/Features/Expect/json.php index 2228fd56..4177f648 100644 --- a/tests/Features/Expect/json.php +++ b/tests/Features/Expect/json.php @@ -6,7 +6,7 @@ test('it properly parses json string', function () { expect('{"name":"Nuno"}') ->json() ->name - ->toBe('Nuno'); + ->toBe('uno'); }); test('fails with broken json string', function () { From 5b310f6f9348669f2bd9a3901ad36bc9e7b1de0f Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 15:58:44 +0100 Subject: [PATCH 02/39] More work on output --- src/Logging/TeamCity.php | 82 +++++++++++++++++++++++++--------- tests/Features/Expect/json.php | 5 +++ 2 files changed, 67 insertions(+), 20 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 8033a798..e9fdc71c 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -6,6 +6,7 @@ namespace Pest\Logging; use function getmypid; use Pest\Concerns\Testable; +use function Pest\version; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; @@ -36,6 +37,9 @@ final class TeamCity extends DefaultResultPrinter /** @var \PHPUnit\Util\Log\TeamCity */ private $phpunitTeamCity; + /** @var array */ + protected $outputStack = []; + public function __construct(bool $verbose, string $colors) { parent::__construct(null, $verbose, $colors, false, 80, false); @@ -47,6 +51,15 @@ final class TeamCity extends DefaultResultPrinter 80, false ); + + $this->logo(); + } + + private function logo() + { + $this->writeNewLine(); + $this->write('Pest ' . version()); + $this->writeNewLine(); } public function printResult(TestResult $result): void @@ -58,6 +71,10 @@ final class TeamCity extends DefaultResultPrinter /** @phpstan-ignore-next-line */ public function startTestSuite(TestSuite $suite): void { + if (!str_contains($suite->getName(), '.php')) { + $this->writeWithColor('bold', substr_replace($suite->getName(), '', 0, 2)); + } + $this->flowId = (int) getmypid(); if (!$this->isSummaryTestCountPrinted) { @@ -176,7 +193,20 @@ final class TeamCity extends DefaultResultPrinter { $this->lastTestFailed = true; $this->writePestTestOutput($test->getName(), 'red', '⨯'); - $this->phpunitTeamCity->addError($test, $t, $time); + + $this->outputStack[] = function () use ($test, $t, $time) { + $this->phpunitTeamCity->addError($test, $t, $time); + }; + } + + public function addFailure(Test $test, AssertionFailedError $e, float $time): void + { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'red', '⨯'); + + $this->outputStack[] = function () use ($test, $e, $time) { + $this->phpunitTeamCity->addFailure($test, $e, $time); + }; } /** @@ -189,34 +219,35 @@ final class TeamCity extends DefaultResultPrinter $this->phpunitTeamCity->addWarning($test, $e, $time); } - public function addRiskyTest(Test $test, Throwable $t, float $time): void + public function addIncompleteTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'yellow', '!', function() use ($t) { + $this->writePestTestOutput($test->getName(), 'yellow', '…', function () use ($t) { $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); }); } - public function addFailure(Test $test, AssertionFailedError $e, float $time): void + public function addRiskyTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'red', '⨯'); - $this->phpunitTeamCity->addFailure($test, $e, $time); - } - - protected function writeProgress(string $progress): void - { - parent::writeProgress($progress); + $this->writePestTestOutput($test->getName(), 'yellow', '!', function () use ($t) { + $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); + }); } public function addSkippedTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'yellow', '-', function() use ($t) { + $this->writePestTestOutput($test->getName(), 'yellow', '-', function () use ($t) { $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); }); } + protected function writeProgress(string $progress): void + { + parent::writeProgress($progress); + } + /** * @param array $params */ @@ -245,31 +276,42 @@ final class TeamCity extends DefaultResultPrinter - $result->warningCount(); } + protected function printHeader(TestResult $result): void + { + foreach ($this->outputStack as $callable) { + $callable(); + } + } + protected function printFooter(TestResult $result): void { + $this->writeNewLine(); $this->writeProgress('Tests: '); $results = [ - 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-yellow'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], + 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-yellow'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-yellow'], - 'passed' => ['count' => $this->countSuccessfulTests($result), 'color' => 'fg-green'], + 'passed' => ['count' => $this->countSuccessfulTests($result), 'color' => 'fg-green'], ]; - $filteredResults = array_filter($results, function($item) { + $filteredResults = array_filter($results, function ($item) { return $item['count'] > 0; }); - foreach ($filteredResults as $key => $result) { - $this->writeProgressWithColor($result['color'], $result['count'] . " $key"); + foreach ($filteredResults as $key => $info) { + $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); if ($key !== array_reverse(array_keys($filteredResults))[0]) { $this->write(', '); } } + $this->writeNewLine(); + $this->write("Time: {$result->time()}s"); + $this->writeNewLine(); } diff --git a/tests/Features/Expect/json.php b/tests/Features/Expect/json.php index 4177f648..475d8b92 100644 --- a/tests/Features/Expect/json.php +++ b/tests/Features/Expect/json.php @@ -9,6 +9,11 @@ test('it properly parses json string', function () { ->toBe('uno'); }); +it('is incomplete'); + +it('doesnt do anything', function () { +}); + test('fails with broken json string', function () { expect('{":"Nuno"}')->json(); })->throws(ExpectationFailedException::class); From e16104350eb9582e5b2fc79d4a03e73fae976426 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 16:45:35 +0100 Subject: [PATCH 03/39] More work on output --- src/Logging/TeamCity.php | 67 ++++++++++++++++++---------------- tests/Features/Expect/json.php | 7 +--- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index e9fdc71c..f45f207c 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -55,7 +55,7 @@ final class TeamCity extends DefaultResultPrinter $this->logo(); } - private function logo() + private function logo(): void { $this->writeNewLine(); $this->write('Pest ' . version()); @@ -72,7 +72,7 @@ final class TeamCity extends DefaultResultPrinter public function startTestSuite(TestSuite $suite): void { if (!str_contains($suite->getName(), '.php')) { - $this->writeWithColor('bold', substr_replace($suite->getName(), '', 0, 2)); + $this->writeWithColor('bg-white, fg-black, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } $this->flowId = (int) getmypid(); @@ -157,7 +157,7 @@ final class TeamCity extends DefaultResultPrinter } if (!$this->lastTestFailed) { - $this->writePestTestOutput($test->getName(), 'green', '✓'); + $this->writePestTestOutput($test->getName(), 'fg-green, bold', '✓'); } if ($test instanceof TestCase) { @@ -174,16 +174,15 @@ final class TeamCity extends DefaultResultPrinter ]); } - protected function writePestTestOutput(string $message, string $color, string $symbol, callable $suffix = null) + private function writePestTestOutput(string $message, string $color, string $symbol, string $suffix = null): void { - $this->writeProgressWithColor("fg-$color, bold", "$symbol "); + $this->writeProgressWithColor($color, "$symbol "); $this->writeProgress($message); - if ($suffix) { - $suffix(); + if ($suffix !== null && strlen($suffix) > 0) { + $suffix = str_replace("\n", ' ', $suffix); + $this->writeWithColor($color, " -> $suffix"); } - - $this->writeNewLine(); } /** @@ -192,9 +191,11 @@ final class TeamCity extends DefaultResultPrinter public function addError(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'red', '⨯'); + $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - $this->outputStack[] = function () use ($test, $t, $time) { + $this->outputStack[] = function () use ($test, $t, $time): void { + $this->writeNewLine(); + $this->writeWithColor('fg-red', "• {$test->getPrintableTestCaseName()} > {$test->getName()}"); $this->phpunitTeamCity->addError($test, $t, $time); }; } @@ -202,9 +203,11 @@ final class TeamCity extends DefaultResultPrinter public function addFailure(Test $test, AssertionFailedError $e, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'red', '⨯'); + $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - $this->outputStack[] = function () use ($test, $e, $time) { + $this->outputStack[] = function () use ($test, $e, $time): void { + $this->writeNewLine(); + $this->writeWithColor('fg-red', "• {$test->getPrintableTestCaseName()} > {$test->getName()}"); $this->phpunitTeamCity->addFailure($test, $e, $time); }; } @@ -216,36 +219,26 @@ final class TeamCity extends DefaultResultPrinter */ public function addWarning(Test $test, Warning $e, float $time): void { - $this->phpunitTeamCity->addWarning($test, $e, $time); + $this->lastTestFailed = true; + $this->writeWarning($test, $e); } public function addIncompleteTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'yellow', '…', function () use ($t) { - $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); - }); + $this->writeWarning($test, $t); } public function addRiskyTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'yellow', '!', function () use ($t) { - $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); - }); + $this->writeWarning($test, $t); } public function addSkippedTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'yellow', '-', function () use ($t) { - $this->writeProgressWithColor('fg-yellow', ' -> ' . $t->getMessage()); - }); - } - - protected function writeProgress(string $progress): void - { - parent::writeProgress($progress); + $this->writeWarning($test, $t); } /** @@ -267,13 +260,20 @@ final class TeamCity extends DefaultResultPrinter $this->write("]\n"); } - protected function countSuccessfulTests(TestResult $result) + private function writeWarning(Test $test, Throwable $t): void + { + $this->writePestTestOutput($test->getName(), 'fg-cyan, bold', '-', $t->getMessage()); + } + + private function successfulTestCount(TestResult $result): int { return $result->count() - $result->failureCount() - $result->errorCount() - $result->skippedCount() - - $result->warningCount(); + - $result->warningCount() + - $result->notImplementedCount() + - $result->riskyCount(); } protected function printHeader(TestResult $result): void @@ -294,10 +294,10 @@ final class TeamCity extends DefaultResultPrinter 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-yellow'], - 'passed' => ['count' => $this->countSuccessfulTests($result), 'color' => 'fg-green'], + 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], ]; - $filteredResults = array_filter($results, function ($item) { + $filteredResults = array_filter($results, function ($item): bool { return $item['count'] > 0; }); @@ -309,6 +309,9 @@ final class TeamCity extends DefaultResultPrinter } } + $this->writeNewLine(); + $this->write("Assertions: $this->numAssertions"); + $this->writeNewLine(); $this->write("Time: {$result->time()}s"); diff --git a/tests/Features/Expect/json.php b/tests/Features/Expect/json.php index 475d8b92..2228fd56 100644 --- a/tests/Features/Expect/json.php +++ b/tests/Features/Expect/json.php @@ -6,12 +6,7 @@ test('it properly parses json string', function () { expect('{"name":"Nuno"}') ->json() ->name - ->toBe('uno'); -}); - -it('is incomplete'); - -it('doesnt do anything', function () { + ->toBe('Nuno'); }); test('fails with broken json string', function () { From e59606818d7ba06fc135e5eb4e07c84c5709e9e0 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 17:26:48 +0100 Subject: [PATCH 04/39] More work on output --- src/Logging/TeamCity.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index f45f207c..5cdeb9e5 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -71,7 +71,7 @@ final class TeamCity extends DefaultResultPrinter /** @phpstan-ignore-next-line */ public function startTestSuite(TestSuite $suite): void { - if (!str_contains($suite->getName(), '.php')) { + if (str_starts_with($suite->getName(), 'P\\')) { $this->writeWithColor('bg-white, fg-black, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } @@ -111,6 +111,10 @@ final class TeamCity extends DefaultResultPrinter { $suiteName = $suite->getName(); + if (str_starts_with($suiteName, 'P\\')) { + $this->writeNewLine(); + } + if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { $this->printEvent( self::TEST_SUITE_FINISHED, [ From 5f315fc89940541d88b654a0431a56879f0a9d2c Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 17:46:30 +0100 Subject: [PATCH 05/39] Updates warning color --- src/Logging/TeamCity.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 5cdeb9e5..2845ca6b 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -294,10 +294,10 @@ final class TeamCity extends DefaultResultPrinter $results = [ 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-yellow'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], - 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-yellow'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], + 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], ]; From 9516e56242151dab1f51adcfa0913361857107c1 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 17:50:18 +0100 Subject: [PATCH 06/39] Improves test case name styling --- src/Logging/TeamCity.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 2845ca6b..4f30b14f 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -37,7 +37,12 @@ final class TeamCity extends DefaultResultPrinter /** @var \PHPUnit\Util\Log\TeamCity */ private $phpunitTeamCity; - /** @var array */ + /** + * A stack of error messages and test failures to be displayed + * once the test suite has finished running. + * + * @var array + */ protected $outputStack = []; public function __construct(bool $verbose, string $colors) @@ -55,6 +60,9 @@ final class TeamCity extends DefaultResultPrinter $this->logo(); } + /** + * Outputs Pest's logo and version number at the top of the output. + */ private function logo(): void { $this->writeNewLine(); @@ -72,7 +80,7 @@ final class TeamCity extends DefaultResultPrinter public function startTestSuite(TestSuite $suite): void { if (str_starts_with($suite->getName(), 'P\\')) { - $this->writeWithColor('bg-white, fg-black, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); + $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } $this->flowId = (int) getmypid(); From f9de1b9c0037b6f6553b18068282c93cd628b833 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 17:51:12 +0100 Subject: [PATCH 07/39] Refactor --- src/Logging/TeamCity.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 4f30b14f..1bfeea71 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -60,9 +60,6 @@ final class TeamCity extends DefaultResultPrinter $this->logo(); } - /** - * Outputs Pest's logo and version number at the top of the output. - */ private function logo(): void { $this->writeNewLine(); From 05f72f9b6df586f8bac10026e06370058b9eb3d4 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 16 Jul 2021 17:59:07 +0100 Subject: [PATCH 08/39] Aligns test case name with test names --- src/Logging/TeamCity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 1bfeea71..63cf7245 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -77,7 +77,7 @@ final class TeamCity extends DefaultResultPrinter public function startTestSuite(TestSuite $suite): void { if (str_starts_with($suite->getName(), 'P\\')) { - $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); + $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } $this->flowId = (int) getmypid(); From d10281f85112aee8964bb918957baa218ca4750f Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 19 Jul 2021 12:59:18 +0100 Subject: [PATCH 09/39] Adds test cases for loggers and removes use of `str_starts_with`. --- src/Actions/AddsDefaults.php | 2 +- src/Logging/TeamCity.php | 24 +++++++++++++++++++----- tests/Visual/JUnit.php | 29 +++++++++++++++++++++++++++++ tests/Visual/TeamCity.php | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 tests/Visual/JUnit.php create mode 100644 tests/Visual/TeamCity.php diff --git a/src/Actions/AddsDefaults.php b/src/Actions/AddsDefaults.php index 9a177a46..f16b8879 100644 --- a/src/Actions/AddsDefaults.php +++ b/src/Actions/AddsDefaults.php @@ -30,7 +30,7 @@ final class AddsDefaults } if ($arguments[self::PRINTER] === \PHPUnit\Util\Log\TeamCity::class) { - $arguments[self::PRINTER] = new TeamCity($arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); + $arguments[self::PRINTER] = new TeamCity(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); } // Load our junit logger instead. diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 63cf7245..97db03e0 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -17,6 +17,7 @@ use PHPUnit\Runner\PhptTestCase; use PHPUnit\TextUI\DefaultResultPrinter; use function round; use function str_replace; +use function strlen; use Throwable; final class TeamCity extends DefaultResultPrinter @@ -45,11 +46,14 @@ final class TeamCity extends DefaultResultPrinter */ protected $outputStack = []; - public function __construct(bool $verbose, string $colors) + /** + * @param resource|string|null $out + */ + public function __construct($out, bool $verbose, string $colors) { - parent::__construct(null, $verbose, $colors, false, 80, false); + parent::__construct($out, $verbose, $colors, false, 80, false); $this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity( - null, + $out, $verbose, $colors, false, @@ -76,7 +80,7 @@ final class TeamCity extends DefaultResultPrinter /** @phpstan-ignore-next-line */ public function startTestSuite(TestSuite $suite): void { - if (str_starts_with($suite->getName(), 'P\\')) { + if (static::isPestTestSuite($suite)) { $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } @@ -116,7 +120,7 @@ final class TeamCity extends DefaultResultPrinter { $suiteName = $suite->getName(); - if (str_starts_with($suiteName, 'P\\')) { + if (static::isPestTestSuite($suite)) { $this->writeNewLine(); } @@ -348,4 +352,14 @@ final class TeamCity extends DefaultResultPrinter return in_array(Testable::class, $uses, true); } + + /** + * Verify that the given test suite is a valid Pest suite. + * + * @param TestSuite $suite + */ + private static function isPestTestSuite(TestSuite $suite): bool + { + return strncmp($suite->getName(), 'P\\', strlen('P\\')) === 0; + } } diff --git a/tests/Visual/JUnit.php b/tests/Visual/JUnit.php new file mode 100644 index 00000000..a12d561f --- /dev/null +++ b/tests/Visual/JUnit.php @@ -0,0 +1,29 @@ +startTestSuite(new TestSuite()); + $junit->startTest($this); + $junit->addError($this, new Exception(), 0); + $junit->addFailure($this, new AssertionFailedError(), 0); + $junit->addWarning($this, new Warning(), 0); + $junit->addIncompleteTest($this, new Exception(), 0); + $junit->addRiskyTest($this, new Exception(), 0); + $junit->addSkippedTest($this, new Exception(), 0); + $junit->endTest($this, 0); + $junit->endTestSuite(new TestSuite()); + $this->expectNotToPerformAssertions(); +}); + +afterEach(function () { + unlink(__DIR__ . '/junit.html'); +}); diff --git a/tests/Visual/TeamCity.php b/tests/Visual/TeamCity.php new file mode 100644 index 00000000..1681f1ac --- /dev/null +++ b/tests/Visual/TeamCity.php @@ -0,0 +1,32 @@ +toBeTrue(); + $teamCity->startTestSuite(new TestSuite()); + $teamCity->startTest($this); + $teamCity->addError($this, new Exception('Don\'t worry about this error. Its purposeful.'), 0); + $teamCity->addFailure($this, new AssertionFailedError('Don\'t worry about this error. Its purposeful.'), 0); + $teamCity->addWarning($this, new Warning(), 0); + $teamCity->addIncompleteTest($this, new Exception(), 0); + $teamCity->addRiskyTest($this, new Exception(), 0); + $teamCity->addSkippedTest($this, new Exception(), 0); + $teamCity->endTest($this, 0); + $teamCity->printResult(new TestResult()); + $teamCity->endTestSuite(new TestSuite()); +}); + +afterEach(function () { + unlink(__DIR__ . '/output.txt'); +}); From 6a84b825e646c5df75e5992719db3f6106d12976 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:23:24 +0100 Subject: [PATCH 10/39] Output improvements. --- composer.json | 2 +- src/Logging/TeamCity.php | 391 +++++++++++++++++------------------ tests/.snapshots/success.txt | 8 +- 3 files changed, 192 insertions(+), 209 deletions(-) diff --git a/composer.json b/composer.json index bee8f8b7..d3feddb8 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "scripts": { "lint": "php-cs-fixer fix -v", "test:lint": "php-cs-fixer fix -v --dry-run", - "test:types": "phpstan analyse --ansi --memory-limit=0", + "test:types": "phpstan analyse --ansi --memory-limit=-1", "test:unit": "php bin/pest --colors=always --exclude-group=integration", "test:integration": "php bin/pest --colors=always --group=integration", "update:snapshots": "REBUILD_SNAPSHOTS=true php bin/pest --colors=always", diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 97db03e0..41f54a24 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -38,14 +38,6 @@ final class TeamCity extends DefaultResultPrinter /** @var \PHPUnit\Util\Log\TeamCity */ private $phpunitTeamCity; - /** - * A stack of error messages and test failures to be displayed - * once the test suite has finished running. - * - * @var array - */ - protected $outputStack = []; - /** * @param resource|string|null $out */ @@ -73,10 +65,55 @@ final class TeamCity extends DefaultResultPrinter public function printResult(TestResult $result): void { - $this->printHeader($result); $this->printFooter($result); } + protected function printFooter(TestResult $result): void + { + $this->writeNewLine(); + $this->writeProgress('Tests: '); + + $results = [ + 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], + 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], + 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], + ]; + + $filteredResults = array_filter($results, function ($item): bool { + return $item['count'] > 0; + }); + + foreach ($filteredResults as $key => $info) { + $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); + + if ($key !== array_reverse(array_keys($filteredResults))[0]) { + $this->write(', '); + } + } + + $this->writeNewLine(); + $this->write("Assertions: $this->numAssertions"); + + $this->writeNewLine(); + $this->write("Time: {$result->time()}s"); + + $this->writeNewLine(); + } + + private function successfulTestCount(TestResult $result): int + { + return $result->count() + - $result->failureCount() + - $result->errorCount() + - $result->skippedCount() + - $result->warningCount() + - $result->notImplementedCount() + - $result->riskyCount(); + } + /** @phpstan-ignore-next-line */ public function startTestSuite(TestSuite $suite): void { @@ -115,143 +152,14 @@ final class TeamCity extends DefaultResultPrinter ]); } - /** @phpstan-ignore-next-line */ - public function endTestSuite(TestSuite $suite): void - { - $suiteName = $suite->getName(); - - if (static::isPestTestSuite($suite)) { - $this->writeNewLine(); - } - - if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { - $this->printEvent( - self::TEST_SUITE_FINISHED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL . $suiteName, - ]); - - return; - } - - $this->printEvent( - self::TEST_SUITE_FINISHED, [ - self::NAME => substr($suiteName, 2), - ]); - } - /** - * @param Test|Testable $test - */ - public function startTest(Test $test): void - { - if (!TeamCity::isPestTest($test)) { - $this->phpunitTeamCity->startTest($test); - - return; - } - - $this->printEvent('testStarted', [ - self::NAME => $test->getName(), - // @phpstan-ignore-next-line - self::LOCATION_HINT => self::PROTOCOL . $test->toString(), - ]); - } - - /** - * @param Test|Testable $test - */ - public function endTest(Test $test, float $time): void - { - if (!TeamCity::isPestTest($test)) { - $this->phpunitTeamCity->endTest($test, $time); - - return; - } - - if (!$this->lastTestFailed) { - $this->writePestTestOutput($test->getName(), 'fg-green, bold', '✓'); - } - - if ($test instanceof TestCase) { - $this->numAssertions += $test->getNumAssertions(); - } elseif ($test instanceof PhptTestCase) { - $this->numAssertions++; - } - - $this->lastTestFailed = false; - - $this->printEvent('testFinished', [ - self::NAME => $test->getName(), - self::DURATION => self::toMilliseconds($time), - ]); - } - - private function writePestTestOutput(string $message, string $color, string $symbol, string $suffix = null): void - { - $this->writeProgressWithColor($color, "$symbol "); - $this->writeProgress($message); - - if ($suffix !== null && strlen($suffix) > 0) { - $suffix = str_replace("\n", ' ', $suffix); - $this->writeWithColor($color, " -> $suffix"); - } - } - - /** - * @param Test|Testable $test - */ - public function addError(Test $test, Throwable $t, float $time): void - { - $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - - $this->outputStack[] = function () use ($test, $t, $time): void { - $this->writeNewLine(); - $this->writeWithColor('fg-red', "• {$test->getPrintableTestCaseName()} > {$test->getName()}"); - $this->phpunitTeamCity->addError($test, $t, $time); - }; - } - - public function addFailure(Test $test, AssertionFailedError $e, float $time): void - { - $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - - $this->outputStack[] = function () use ($test, $e, $time): void { - $this->writeNewLine(); - $this->writeWithColor('fg-red', "• {$test->getPrintableTestCaseName()} > {$test->getName()}"); - $this->phpunitTeamCity->addFailure($test, $e, $time); - }; - } - - /** - * @phpstan-ignore-next-line + * Verify that the given test suite is a valid Pest suite. * - * @param Test|Testable $test + * @param TestSuite $suite */ - public function addWarning(Test $test, Warning $e, float $time): void + private static function isPestTestSuite(TestSuite $suite): bool { - $this->lastTestFailed = true; - $this->writeWarning($test, $e); - } - - public function addIncompleteTest(Test $test, Throwable $t, float $time): void - { - $this->lastTestFailed = true; - $this->writeWarning($test, $t); - } - - public function addRiskyTest(Test $test, Throwable $t, float $time): void - { - $this->lastTestFailed = true; - $this->writeWarning($test, $t); - } - - public function addSkippedTest(Test $test, Throwable $t, float $time): void - { - $this->lastTestFailed = true; - $this->writeWarning($test, $t); + return strncmp($suite->getName(), 'P\\', strlen('P\\')) === 0; } /** @@ -273,64 +181,6 @@ final class TeamCity extends DefaultResultPrinter $this->write("]\n"); } - private function writeWarning(Test $test, Throwable $t): void - { - $this->writePestTestOutput($test->getName(), 'fg-cyan, bold', '-', $t->getMessage()); - } - - private function successfulTestCount(TestResult $result): int - { - return $result->count() - - $result->failureCount() - - $result->errorCount() - - $result->skippedCount() - - $result->warningCount() - - $result->notImplementedCount() - - $result->riskyCount(); - } - - protected function printHeader(TestResult $result): void - { - foreach ($this->outputStack as $callable) { - $callable(); - } - } - - protected function printFooter(TestResult $result): void - { - $this->writeNewLine(); - $this->writeProgress('Tests: '); - - $results = [ - 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], - 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], - 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], - ]; - - $filteredResults = array_filter($results, function ($item): bool { - return $item['count'] > 0; - }); - - foreach ($filteredResults as $key => $info) { - $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); - - if ($key !== array_reverse(array_keys($filteredResults))[0]) { - $this->write(', '); - } - } - - $this->writeNewLine(); - $this->write("Assertions: $this->numAssertions"); - - $this->writeNewLine(); - $this->write("Time: {$result->time()}s"); - - $this->writeNewLine(); - } - private static function escapeValue(string $text): string { return str_replace( @@ -340,9 +190,47 @@ final class TeamCity extends DefaultResultPrinter ); } - private static function toMilliseconds(float $time): int + /** @phpstan-ignore-next-line */ + public function endTestSuite(TestSuite $suite): void { - return (int) round($time * 1000); + $suiteName = $suite->getName(); + + if (static::isPestTestSuite($suite)) { + $this->writeNewLine(); + } + + if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { + $this->printEvent( + self::TEST_SUITE_FINISHED, [ + self::NAME => $suiteName, + self::LOCATION_HINT => self::PROTOCOL . $suiteName, + ]); + + return; + } + + $this->printEvent( + self::TEST_SUITE_FINISHED, [ + self::NAME => substr($suiteName, 2), + ]); + } + + /** + * @param Test|Testable $test + */ + public function startTest(Test $test): void + { + if (!TeamCity::isPestTest($test)) { + $this->phpunitTeamCity->startTest($test); + + return; + } + + $this->printEvent('testStarted', [ + self::NAME => $test->getName(), + // @phpstan-ignore-next-line + self::LOCATION_HINT => self::PROTOCOL . $test->toString(), + ]); } public static function isPestTest(Test $test): bool @@ -354,12 +242,101 @@ final class TeamCity extends DefaultResultPrinter } /** - * Verify that the given test suite is a valid Pest suite. - * - * @param TestSuite $suite + * @param Test|Testable $test */ - private static function isPestTestSuite(TestSuite $suite): bool + public function endTest(Test $test, float $time): void { - return strncmp($suite->getName(), 'P\\', strlen('P\\')) === 0; + if (!TeamCity::isPestTest($test)) { + $this->phpunitTeamCity->endTest($test, $time); + + return; + } + + $this->printEvent('testFinished', [ + self::NAME => $test->getName(), + self::DURATION => self::toMilliseconds($time), + ]); + + if (!$this->lastTestFailed) { + $this->writePestTestOutput($test->getName(), 'fg-green, bold', '✓'); + } + + if ($test instanceof TestCase) { + $this->numAssertions += $test->getNumAssertions(); + } elseif ($test instanceof PhptTestCase) { + $this->numAssertions++; + } + + $this->lastTestFailed = false; + } + + private function writePestTestOutput(string $message, string $color, string $symbol, string $suffix = null): void + { + $this->writeProgressWithColor($color, "$symbol "); + $this->writeProgress($message); + + if ($suffix !== null && strlen($suffix) > 0) { + $suffix = str_replace("\n", ' ', $suffix); + $this->writeWithColor($color, " -> $suffix"); + } + } + + private static function toMilliseconds(float $time): int + { + return (int) round($time * 1000); + } + + /** + * @param Test|Testable $test + */ + public function addError(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); + + $this->phpunitTeamCity->addError($test, $t, $time); + } + + public function addFailure(Test $test, AssertionFailedError $e, float $time): void + { + $this->lastTestFailed = true; + $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); + + $this->phpunitTeamCity->addFailure($test, $e, $time); + } + + /** + * @phpstan-ignore-next-line + * + * @param Test|Testable $test + */ + public function addWarning(Test $test, Warning $e, float $time): void + { + $this->lastTestFailed = true; + $this->writeWarning($test, $e); + } + + private function writeWarning(Test $test, Throwable $t): void + { + $this->writePestTestOutput($test->getName(), 'fg-yellow, bold', '-', $t->getMessage()); + } + + public function addIncompleteTest(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writeWarning($test, $t); + } + + public function addRiskyTest(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writeWarning($test, $t); + } + + public function addSkippedTest(Test $test, Throwable $t, float $time): void + { + $this->lastTestFailed = true; + $this->writeWarning($test, $t); + $this->phpunitTeamCity->printIgnoredTest($test->getName(), $t, $time); } } diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 0a23a6e9..fa2b86fa 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -578,6 +578,9 @@ PASS Tests\Visual\Help ✓ visual snapshot of help command output + PASS Tests\Visual\JUnit + ✓ it is can successfully call all public methods + PASS Tests\Visual\SingleTestOrDirectory ✓ allows to run a single test ✓ allows to run a directory @@ -587,6 +590,9 @@ WARN Tests\Visual\Success - visual snapshot of test suite on success + PASS Tests\Visual\TeamCity + ✓ it is can successfully call all public methods + PASS Tests\Features\Depends ✓ first ✓ second @@ -601,5 +607,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 4 incompleted, 9 skipped, 381 passed + Tests: 4 incompleted, 9 skipped, 383 passed \ No newline at end of file From 12fb4f86390dc8f8fb1c4cc32c00ecedf4e19115 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:24:23 +0100 Subject: [PATCH 11/39] Output improvements. --- src/Logging/TeamCity.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 41f54a24..e18ff1de 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -213,6 +213,8 @@ final class TeamCity extends DefaultResultPrinter self::TEST_SUITE_FINISHED, [ self::NAME => substr($suiteName, 2), ]); + + $this->writeNewLine(); } /** From 0f7c8d00d6a4060ca0c81811d9cb0c73211cf2af Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:29:39 +0100 Subject: [PATCH 12/39] Output improvements. --- src/Logging/TeamCity.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index e18ff1de..3db4daa9 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -249,9 +249,7 @@ final class TeamCity extends DefaultResultPrinter public function endTest(Test $test, float $time): void { if (!TeamCity::isPestTest($test)) { - $this->phpunitTeamCity->endTest($test, $time); - - return; + parent::endTest($test, $time); } $this->printEvent('testFinished', [ From 04d8a3762b72708b3bd0084effcd5635f76f314f Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:31:03 +0100 Subject: [PATCH 13/39] Output improvements. --- src/Logging/TeamCity.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 3db4daa9..cadde92f 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -119,6 +119,8 @@ final class TeamCity extends DefaultResultPrinter { if (static::isPestTestSuite($suite)) { $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); + } else { + $this->writeWithColor('fg-white, bold', ' ' . $suite->getName()); } $this->flowId = (int) getmypid(); From 8b39df68cec055a438688cee87b472bea31ad410 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:32:27 +0100 Subject: [PATCH 14/39] Output improvements. --- src/Logging/TeamCity.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index cadde92f..8e5288e6 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -250,10 +250,6 @@ final class TeamCity extends DefaultResultPrinter */ public function endTest(Test $test, float $time): void { - if (!TeamCity::isPestTest($test)) { - parent::endTest($test, $time); - } - $this->printEvent('testFinished', [ self::NAME => $test->getName(), self::DURATION => self::toMilliseconds($time), From 5ed45457375922a92f9778dece5a0716cc683863 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:34:10 +0100 Subject: [PATCH 15/39] Output improvements. --- src/Logging/TeamCity.php | 75 ++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 8e5288e6..46c8b12f 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -22,11 +22,11 @@ use Throwable; final class TeamCity extends DefaultResultPrinter { - private const PROTOCOL = 'pest_qn://'; - private const NAME = 'name'; - private const LOCATION_HINT = 'locationHint'; - private const DURATION = 'duration'; - private const TEST_SUITE_STARTED = 'testSuiteStarted'; + private const PROTOCOL = 'pest_qn://'; + private const NAME = 'name'; + private const LOCATION_HINT = 'locationHint'; + private const DURATION = 'duration'; + private const TEST_SUITE_STARTED = 'testSuiteStarted'; private const TEST_SUITE_FINISHED = 'testSuiteFinished'; /** @var int */ @@ -39,7 +39,7 @@ final class TeamCity extends DefaultResultPrinter private $phpunitTeamCity; /** - * @param resource|string|null $out + * @param resource|string|null $out */ public function __construct($out, bool $verbose, string $colors) { @@ -59,7 +59,7 @@ final class TeamCity extends DefaultResultPrinter private function logo(): void { $this->writeNewLine(); - $this->write('Pest ' . version()); + $this->write('Pest '.version()); $this->writeNewLine(); } @@ -74,12 +74,12 @@ final class TeamCity extends DefaultResultPrinter $this->writeProgress('Tests: '); $results = [ - 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], + 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], - 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], + 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], ]; $filteredResults = array_filter($results, function ($item): bool { @@ -87,7 +87,7 @@ final class TeamCity extends DefaultResultPrinter }); foreach ($filteredResults as $key => $info) { - $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); + $this->writeProgressWithColor($info['color'], $info['count']." $key"); if ($key !== array_reverse(array_keys($filteredResults))[0]) { $this->write(', '); @@ -118,9 +118,7 @@ final class TeamCity extends DefaultResultPrinter public function startTestSuite(TestSuite $suite): void { if (static::isPestTestSuite($suite)) { - $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); - } else { - $this->writeWithColor('fg-white, bold', ' ' . $suite->getName()); + $this->writeWithColor('fg-white, bold', ' '.substr_replace($suite->getName(), '', 0, 2).' '); } $this->flowId = (int) getmypid(); @@ -138,8 +136,8 @@ final class TeamCity extends DefaultResultPrinter if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { $this->printEvent( self::TEST_SUITE_STARTED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL . $suiteName, + self::NAME => $suiteName, + self::LOCATION_HINT => self::PROTOCOL.$suiteName, ]); return; @@ -149,15 +147,15 @@ final class TeamCity extends DefaultResultPrinter $this->printEvent( self::TEST_SUITE_STARTED, [ - self::NAME => substr($suiteName, 2), - self::LOCATION_HINT => self::PROTOCOL . $fileName, + self::NAME => substr($suiteName, 2), + self::LOCATION_HINT => self::PROTOCOL.$fileName, ]); } /** * Verify that the given test suite is a valid Pest suite. * - * @param TestSuite $suite + * @param TestSuite $suite */ private static function isPestTestSuite(TestSuite $suite): bool { @@ -165,7 +163,7 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param array $params + * @param array $params */ private function printEvent(string $eventName, array $params = []): void { @@ -196,16 +194,13 @@ final class TeamCity extends DefaultResultPrinter public function endTestSuite(TestSuite $suite): void { $suiteName = $suite->getName(); - - if (static::isPestTestSuite($suite)) { - $this->writeNewLine(); - } + $this->writeNewLine(); if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { $this->printEvent( self::TEST_SUITE_FINISHED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL . $suiteName, + self::NAME => $suiteName, + self::LOCATION_HINT => self::PROTOCOL.$suiteName, ]); return; @@ -215,12 +210,10 @@ final class TeamCity extends DefaultResultPrinter self::TEST_SUITE_FINISHED, [ self::NAME => substr($suiteName, 2), ]); - - $this->writeNewLine(); } /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function startTest(Test $test): void { @@ -233,7 +226,7 @@ final class TeamCity extends DefaultResultPrinter $this->printEvent('testStarted', [ self::NAME => $test->getName(), // @phpstan-ignore-next-line - self::LOCATION_HINT => self::PROTOCOL . $test->toString(), + self::LOCATION_HINT => self::PROTOCOL.$test->toString(), ]); } @@ -246,12 +239,12 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function endTest(Test $test, float $time): void { $this->printEvent('testFinished', [ - self::NAME => $test->getName(), + self::NAME => $test->getName(), self::DURATION => self::toMilliseconds($time), ]); @@ -268,6 +261,11 @@ final class TeamCity extends DefaultResultPrinter $this->lastTestFailed = false; } + private static function toMilliseconds(float $time): int + { + return (int) round($time * 1000); + } + private function writePestTestOutput(string $message, string $color, string $symbol, string $suffix = null): void { $this->writeProgressWithColor($color, "$symbol "); @@ -279,13 +277,8 @@ final class TeamCity extends DefaultResultPrinter } } - private static function toMilliseconds(float $time): int - { - return (int) round($time * 1000); - } - /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function addError(Test $test, Throwable $t, float $time): void { @@ -306,7 +299,7 @@ final class TeamCity extends DefaultResultPrinter /** * @phpstan-ignore-next-line * - * @param Test|Testable $test + * @param Test|Testable $test */ public function addWarning(Test $test, Warning $e, float $time): void { From e52c83e5beadd88cedc4ec07e7d5ea994a251d79 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:35:20 +0100 Subject: [PATCH 16/39] Output improvements. --- src/Logging/TeamCity.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 46c8b12f..036c9c0a 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -119,6 +119,8 @@ final class TeamCity extends DefaultResultPrinter { if (static::isPestTestSuite($suite)) { $this->writeWithColor('fg-white, bold', ' '.substr_replace($suite->getName(), '', 0, 2).' '); + } else { + $this->writeWithColor('fg-white, bold', ' '.$suite->getName()); } $this->flowId = (int) getmypid(); @@ -194,6 +196,8 @@ final class TeamCity extends DefaultResultPrinter public function endTestSuite(TestSuite $suite): void { $suiteName = $suite->getName(); + + $this->writeNewLine(); $this->writeNewLine(); if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { From 1abab8d440b13c1fa12a36aa72a9f3afd33d4419 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:36:52 +0100 Subject: [PATCH 17/39] Output improvements. --- src/Logging/TeamCity.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 036c9c0a..64136345 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -70,7 +70,6 @@ final class TeamCity extends DefaultResultPrinter protected function printFooter(TestResult $result): void { - $this->writeNewLine(); $this->writeProgress('Tests: '); $results = [ From 2996135155fd7ae282f43d9745cb5a8796b995af Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:38:13 +0100 Subject: [PATCH 18/39] Output improvements. --- src/Logging/TeamCity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 64136345..bcabf1e7 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -118,7 +118,7 @@ final class TeamCity extends DefaultResultPrinter { if (static::isPestTestSuite($suite)) { $this->writeWithColor('fg-white, bold', ' '.substr_replace($suite->getName(), '', 0, 2).' '); - } else { + } elseif ($suite->count() === 1) { $this->writeWithColor('fg-white, bold', ' '.$suite->getName()); } From 7471c224fa45909da3b049473f9fcfd58fae305f Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:39:20 +0100 Subject: [PATCH 19/39] Output improvements. --- src/Logging/TeamCity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index bcabf1e7..64136345 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -118,7 +118,7 @@ final class TeamCity extends DefaultResultPrinter { if (static::isPestTestSuite($suite)) { $this->writeWithColor('fg-white, bold', ' '.substr_replace($suite->getName(), '', 0, 2).' '); - } elseif ($suite->count() === 1) { + } else { $this->writeWithColor('fg-white, bold', ' '.$suite->getName()); } From a7860b0b8e7579e650020d6af6ff5e084dcf1c9c Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 12:41:57 +0100 Subject: [PATCH 20/39] CS --- src/Logging/TeamCity.php | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 64136345..2d0b3426 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -22,11 +22,11 @@ use Throwable; final class TeamCity extends DefaultResultPrinter { - private const PROTOCOL = 'pest_qn://'; - private const NAME = 'name'; - private const LOCATION_HINT = 'locationHint'; - private const DURATION = 'duration'; - private const TEST_SUITE_STARTED = 'testSuiteStarted'; + private const PROTOCOL = 'pest_qn://'; + private const NAME = 'name'; + private const LOCATION_HINT = 'locationHint'; + private const DURATION = 'duration'; + private const TEST_SUITE_STARTED = 'testSuiteStarted'; private const TEST_SUITE_FINISHED = 'testSuiteFinished'; /** @var int */ @@ -39,7 +39,7 @@ final class TeamCity extends DefaultResultPrinter private $phpunitTeamCity; /** - * @param resource|string|null $out + * @param resource|string|null $out */ public function __construct($out, bool $verbose, string $colors) { @@ -59,7 +59,7 @@ final class TeamCity extends DefaultResultPrinter private function logo(): void { $this->writeNewLine(); - $this->write('Pest '.version()); + $this->write('Pest ' . version()); $this->writeNewLine(); } @@ -73,12 +73,12 @@ final class TeamCity extends DefaultResultPrinter $this->writeProgress('Tests: '); $results = [ - 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], + 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], - 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], + 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], ]; $filteredResults = array_filter($results, function ($item): bool { @@ -86,7 +86,7 @@ final class TeamCity extends DefaultResultPrinter }); foreach ($filteredResults as $key => $info) { - $this->writeProgressWithColor($info['color'], $info['count']." $key"); + $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); if ($key !== array_reverse(array_keys($filteredResults))[0]) { $this->write(', '); @@ -117,9 +117,9 @@ final class TeamCity extends DefaultResultPrinter public function startTestSuite(TestSuite $suite): void { if (static::isPestTestSuite($suite)) { - $this->writeWithColor('fg-white, bold', ' '.substr_replace($suite->getName(), '', 0, 2).' '); + $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); } else { - $this->writeWithColor('fg-white, bold', ' '.$suite->getName()); + $this->writeWithColor('fg-white, bold', ' ' . $suite->getName()); } $this->flowId = (int) getmypid(); @@ -137,8 +137,8 @@ final class TeamCity extends DefaultResultPrinter if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { $this->printEvent( self::TEST_SUITE_STARTED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL.$suiteName, + self::NAME => $suiteName, + self::LOCATION_HINT => self::PROTOCOL . $suiteName, ]); return; @@ -148,15 +148,15 @@ final class TeamCity extends DefaultResultPrinter $this->printEvent( self::TEST_SUITE_STARTED, [ - self::NAME => substr($suiteName, 2), - self::LOCATION_HINT => self::PROTOCOL.$fileName, + self::NAME => substr($suiteName, 2), + self::LOCATION_HINT => self::PROTOCOL . $fileName, ]); } /** * Verify that the given test suite is a valid Pest suite. * - * @param TestSuite $suite + * @param TestSuite $suite */ private static function isPestTestSuite(TestSuite $suite): bool { @@ -164,7 +164,7 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param array $params + * @param array $params */ private function printEvent(string $eventName, array $params = []): void { @@ -202,8 +202,8 @@ final class TeamCity extends DefaultResultPrinter if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { $this->printEvent( self::TEST_SUITE_FINISHED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL.$suiteName, + self::NAME => $suiteName, + self::LOCATION_HINT => self::PROTOCOL . $suiteName, ]); return; @@ -216,7 +216,7 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function startTest(Test $test): void { @@ -229,7 +229,7 @@ final class TeamCity extends DefaultResultPrinter $this->printEvent('testStarted', [ self::NAME => $test->getName(), // @phpstan-ignore-next-line - self::LOCATION_HINT => self::PROTOCOL.$test->toString(), + self::LOCATION_HINT => self::PROTOCOL . $test->toString(), ]); } @@ -242,12 +242,12 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function endTest(Test $test, float $time): void { $this->printEvent('testFinished', [ - self::NAME => $test->getName(), + self::NAME => $test->getName(), self::DURATION => self::toMilliseconds($time), ]); @@ -281,7 +281,7 @@ final class TeamCity extends DefaultResultPrinter } /** - * @param Test|Testable $test + * @param Test|Testable $test */ public function addError(Test $test, Throwable $t, float $time): void { @@ -302,7 +302,7 @@ final class TeamCity extends DefaultResultPrinter /** * @phpstan-ignore-next-line * - * @param Test|Testable $test + * @param Test|Testable $test */ public function addWarning(Test $test, Warning $e, float $time): void { From 24b9160b79aacd60507d1e451b7a2aca806ecf47 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 15:34:31 +0100 Subject: [PATCH 21/39] Removes new line from event printing --- src/Logging/TeamCity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 2d0b3426..494aa8c8 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -168,7 +168,7 @@ final class TeamCity extends DefaultResultPrinter */ private function printEvent(string $eventName, array $params = []): void { - $this->write("\n##teamcity[{$eventName}"); + $this->write("##teamcity[{$eventName}"); if ($this->flowId !== 0) { $params['flowId'] = $this->flowId; From df172d8eed796fa5653d0e7ff6b6ecdd95cd3556 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 15:36:38 +0100 Subject: [PATCH 22/39] Adds new lines --- src/Logging/TeamCity.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 494aa8c8..a8713172 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -122,6 +122,8 @@ final class TeamCity extends DefaultResultPrinter $this->writeWithColor('fg-white, bold', ' ' . $suite->getName()); } + $this->writeNewLine(); + $this->flowId = (int) getmypid(); if (!$this->isSummaryTestCountPrinted) { @@ -255,6 +257,8 @@ final class TeamCity extends DefaultResultPrinter $this->writePestTestOutput($test->getName(), 'fg-green, bold', '✓'); } + $this->writeNewLine(); + if ($test instanceof TestCase) { $this->numAssertions += $test->getNumAssertions(); } elseif ($test instanceof PhptTestCase) { From 46337b8085726d3c958eb9ef21716b7895335424 Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 16:32:00 +0100 Subject: [PATCH 23/39] Removes pest from stack traces --- src/Logging/TeamCity.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index a8713172..d763c6ec 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace Pest\Logging; +use ReflectionClass; +use ReflectionProperty; use function getmypid; use Pest\Concerns\Testable; use function Pest\version; @@ -292,6 +294,7 @@ final class TeamCity extends DefaultResultPrinter $this->lastTestFailed = true; $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); + $this->removePestFromStackTrace($t); $this->phpunitTeamCity->addError($test, $t, $time); } @@ -300,9 +303,28 @@ final class TeamCity extends DefaultResultPrinter $this->lastTestFailed = true; $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); + $this->removePestFromStackTrace($e); $this->phpunitTeamCity->addFailure($test, $e, $time); } + private function removePestFromStackTrace(Throwable $e): void + { + $property = new ReflectionProperty($e, 'serializableTrace'); + $property->setAccessible(true); + $trace = $property->getValue($e); + + $cleanedTrace = []; + foreach ($trace as $item) { + if (key_exists('file', $item) && mb_strpos($item['file'], 'vendor/pestphp/pest/') > 0) { + continue; + } + + $cleanedTrace[] = $item; + } + + $property->setValue($e, $cleanedTrace); + } + /** * @phpstan-ignore-next-line * From c2b86c3ab3e5517564532d8dcb2dc12e1726367d Mon Sep 17 00:00:00 2001 From: luke Date: Fri, 30 Jul 2021 16:34:30 +0100 Subject: [PATCH 24/39] Removes pest from stack traces --- src/Logging/TeamCity.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index d763c6ec..8ff92b6f 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -333,6 +333,8 @@ final class TeamCity extends DefaultResultPrinter public function addWarning(Test $test, Warning $e, float $time): void { $this->lastTestFailed = true; + + $this->removePestFromStackTrace($e); $this->writeWarning($test, $e); } @@ -344,18 +346,24 @@ final class TeamCity extends DefaultResultPrinter public function addIncompleteTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; + + $this->removePestFromStackTrace($t); $this->writeWarning($test, $t); } public function addRiskyTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; + + $this->removePestFromStackTrace($t); $this->writeWarning($test, $t); } public function addSkippedTest(Test $test, Throwable $t, float $time): void { $this->lastTestFailed = true; + + $this->removePestFromStackTrace($t); $this->writeWarning($test, $t); $this->phpunitTeamCity->printIgnoredTest($test->getName(), $t, $time); } From 8861dd2401716150c868282089075300e09ba8fa Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 1 Aug 2021 15:40:34 +0100 Subject: [PATCH 25/39] Merges with master --- src/Logging/TeamCity.php | 7 +++++-- tests/.snapshots/success.txt | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 8ff92b6f..58c329e1 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Pest\Logging; -use ReflectionClass; -use ReflectionProperty; use function getmypid; use Pest\Concerns\Testable; use function Pest\version; @@ -17,6 +15,7 @@ use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; use PHPUnit\Runner\PhptTestCase; use PHPUnit\TextUI\DefaultResultPrinter; +use ReflectionProperty; use function round; use function str_replace; use function strlen; @@ -309,6 +308,10 @@ final class TeamCity extends DefaultResultPrinter private function removePestFromStackTrace(Throwable $e): void { + if (!property_exists($e, 'serializableTrace')) { + return; + } + $property = new ReflectionProperty($e, 'serializableTrace'); $property->setAccessible(true); $trace = $property->getValue($e); diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 57bc7e1d..9790bb20 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -585,6 +585,9 @@ PASS Tests\Visual\Help ✓ visual snapshot of help command output + PASS Tests\Visual\JUnit + ✓ it is can successfully call all public methods + PASS Tests\Visual\SingleTestOrDirectory ✓ allows to run a single test ✓ allows to run a directory @@ -594,6 +597,9 @@ WARN Tests\Visual\Success - visual snapshot of test suite on success + PASS Tests\Visual\TeamCity + ✓ it is can successfully call all public methods + PASS Tests\Features\Depends ✓ first ✓ second @@ -608,5 +614,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 4 incompleted, 9 skipped, 388 passed + Tests: 4 incompleted, 9 skipped, 390 passed \ No newline at end of file From b5959aa3fa70ce3eba4c6e16728733820ea309b5 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 1 Aug 2021 15:42:52 +0100 Subject: [PATCH 26/39] Refactors --- src/Actions/AddsDefaults.php | 2 +- src/Logging/TeamCity.php | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Actions/AddsDefaults.php b/src/Actions/AddsDefaults.php index f16b8879..9a177a46 100644 --- a/src/Actions/AddsDefaults.php +++ b/src/Actions/AddsDefaults.php @@ -30,7 +30,7 @@ final class AddsDefaults } if ($arguments[self::PRINTER] === \PHPUnit\Util\Log\TeamCity::class) { - $arguments[self::PRINTER] = new TeamCity(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); + $arguments[self::PRINTER] = new TeamCity($arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); } // Load our junit logger instead. diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 58c329e1..0305c2ec 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -42,17 +42,10 @@ final class TeamCity extends DefaultResultPrinter /** * @param resource|string|null $out */ - public function __construct($out, bool $verbose, string $colors) + public function __construct(bool $verbose, string $colors) { - parent::__construct($out, $verbose, $colors, false, 80, false); - $this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity( - $out, - $verbose, - $colors, - false, - 80, - false - ); + parent::__construct(null, $verbose, $colors); + $this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity(null, $verbose, $colors); $this->logo(); } From 1a941d7f92358691afba9a488bef0b2c438cbe3a Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 1 Aug 2021 16:45:06 +0100 Subject: [PATCH 27/39] Refactors --- src/Actions/AddsDefaults.php | 2 +- src/Concerns/Logging/WritesToConsole.php | 33 ++++ src/Logging/TeamCity.php | 215 ++++++++--------------- src/Support/ExceptionTrace.php | 27 +++ 4 files changed, 133 insertions(+), 144 deletions(-) create mode 100644 src/Concerns/Logging/WritesToConsole.php diff --git a/src/Actions/AddsDefaults.php b/src/Actions/AddsDefaults.php index 9a177a46..f16b8879 100644 --- a/src/Actions/AddsDefaults.php +++ b/src/Actions/AddsDefaults.php @@ -30,7 +30,7 @@ final class AddsDefaults } if ($arguments[self::PRINTER] === \PHPUnit\Util\Log\TeamCity::class) { - $arguments[self::PRINTER] = new TeamCity($arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); + $arguments[self::PRINTER] = new TeamCity(null, $arguments['verbose'] ?? false, $arguments['colors'] ?? DefaultResultPrinter::COLOR_ALWAYS); } // Load our junit logger instead. diff --git a/src/Concerns/Logging/WritesToConsole.php b/src/Concerns/Logging/WritesToConsole.php new file mode 100644 index 00000000..a2965bcb --- /dev/null +++ b/src/Concerns/Logging/WritesToConsole.php @@ -0,0 +1,33 @@ +writePestTestOutput($message, 'fg-green, bold', '✓'); + } + + private function writeError(string $message): void + { + $this->writePestTestOutput($message, 'fg-red, bold', '⨯'); + } + + private function writeWarning(string $message): void + { + $this->writePestTestOutput($message, 'fg-yellow, bold', '-'); + } + + private function writePestTestOutput(string $message, string $color, string $symbol): void + { + $this->writeWithColor($color, "$symbol ", false); + $this->write($message); + $this->writeNewLine(); + } +} diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 0305c2ec..9b7936cb 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace Pest\Logging; use function getmypid; +use Pest\Concerns\Logging\WritesToConsole; use Pest\Concerns\Testable; +use Pest\Support\ExceptionTrace; use function Pest\version; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Test; @@ -13,9 +15,7 @@ use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestResult; use PHPUnit\Framework\TestSuite; use PHPUnit\Framework\Warning; -use PHPUnit\Runner\PhptTestCase; use PHPUnit\TextUI\DefaultResultPrinter; -use ReflectionProperty; use function round; use function str_replace; use function strlen; @@ -23,12 +23,14 @@ use Throwable; final class TeamCity extends DefaultResultPrinter { + use WritesToConsole; private const PROTOCOL = 'pest_qn://'; private const NAME = 'name'; private const LOCATION_HINT = 'locationHint'; private const DURATION = 'duration'; private const TEST_SUITE_STARTED = 'testSuiteStarted'; private const TEST_SUITE_FINISHED = 'testSuiteFinished'; + private const TEST_COUNT = 'testCount'; /** @var int */ private $flowId; @@ -42,10 +44,10 @@ final class TeamCity extends DefaultResultPrinter /** * @param resource|string|null $out */ - public function __construct(bool $verbose, string $colors) + public function __construct($out, bool $verbose, string $colors) { - parent::__construct(null, $verbose, $colors); - $this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity(null, $verbose, $colors); + parent::__construct($out, $verbose, $colors); + $this->phpunitTeamCity = new \PHPUnit\Util\Log\TeamCity($out, $verbose, $colors); $this->logo(); } @@ -59,19 +61,14 @@ final class TeamCity extends DefaultResultPrinter public function printResult(TestResult $result): void { - $this->printFooter($result); - } - - protected function printFooter(TestResult $result): void - { - $this->writeProgress('Tests: '); + $this->write('Tests: '); $results = [ 'failed' => ['count' => $result->errorCount() + $result->failureCount(), 'color' => 'fg-red'], - 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-cyan'], - 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-cyan'], - 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-cyan'], - 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-cyan'], + 'skipped' => ['count' => $result->skippedCount(), 'color' => 'fg-yellow'], + 'warned' => ['count' => $result->warningCount(), 'color' => 'fg-yellow'], + 'risked' => ['count' => $result->riskyCount(), 'color' => 'fg-yellow'], + 'incomplete' => ['count' => $result->notImplementedCount(), 'color' => 'fg-yellow'], 'passed' => ['count' => $this->successfulTestCount($result), 'color' => 'fg-green'], ]; @@ -80,7 +77,7 @@ final class TeamCity extends DefaultResultPrinter }); foreach ($filteredResults as $key => $info) { - $this->writeProgressWithColor($info['color'], $info['count'] . " $key"); + $this->writeWithColor($info['color'], $info['count'] . " $key", false); if ($key !== array_reverse(array_keys($filteredResults))[0]) { $this->write(', '); @@ -110,10 +107,14 @@ final class TeamCity extends DefaultResultPrinter /** @phpstan-ignore-next-line */ public function startTestSuite(TestSuite $suite): void { - if (static::isPestTestSuite($suite)) { - $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suite->getName(), '', 0, 2) . ' '); + $suiteName = $suite->getName(); + + if (static::isCompoundTestSuite($suite)) { + $this->writeWithColor('bold', ' ' . $suiteName); + } elseif (static::isPestTestSuite($suite)) { + $this->writeWithColor('fg-white, bold', ' ' . substr_replace($suiteName, '', 0, 2) . ' '); } else { - $this->writeWithColor('fg-white, bold', ' ' . $suite->getName()); + $this->writeWithColor('fg-white, bold', ' ' . $suiteName); } $this->writeNewLine(); @@ -121,44 +122,18 @@ final class TeamCity extends DefaultResultPrinter $this->flowId = (int) getmypid(); if (!$this->isSummaryTestCountPrinted) { - $this->printEvent( - 'testCount', - ['count' => $suite->count()] - ); + $this->printEvent(self::TEST_COUNT, [ + 'count' => $suite->count(), + ]); $this->isSummaryTestCountPrinted = true; } - $suiteName = $suite->getName(); - - if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { - $this->printEvent( - self::TEST_SUITE_STARTED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL . $suiteName, - ]); - - return; - } - - $fileName = $suiteName::__getFileName(); - - $this->printEvent( - self::TEST_SUITE_STARTED, [ - self::NAME => substr($suiteName, 2), - self::LOCATION_HINT => self::PROTOCOL . $fileName, + $this->printEvent(self::TEST_SUITE_STARTED, [ + self::NAME => static::isCompoundTestSuite($suite) ? $suiteName : substr($suiteName, 2), + self::LOCATION_HINT => self::PROTOCOL . (static::isCompoundTestSuite($suite) ? $suiteName : $suiteName::__getFileName()), ]); } - /** - * Verify that the given test suite is a valid Pest suite. - * - * @param TestSuite $suite - */ - private static function isPestTestSuite(TestSuite $suite): bool - { - return strncmp($suite->getName(), 'P\\', strlen('P\\')) === 0; - } - /** * @param array $params */ @@ -195,19 +170,9 @@ final class TeamCity extends DefaultResultPrinter $this->writeNewLine(); $this->writeNewLine(); - if (file_exists($suiteName) || !method_exists($suiteName, '__getFileName')) { - $this->printEvent( - self::TEST_SUITE_FINISHED, [ - self::NAME => $suiteName, - self::LOCATION_HINT => self::PROTOCOL . $suiteName, - ]); - - return; - } - - $this->printEvent( - self::TEST_SUITE_FINISHED, [ - self::NAME => substr($suiteName, 2), + $this->printEvent(self::TEST_SUITE_FINISHED, [ + self::NAME => static::isCompoundTestSuite($suite) ? $suiteName : substr($suiteName, 2), + self::LOCATION_HINT => self::PROTOCOL . (static::isCompoundTestSuite($suite) ? $suiteName : $suiteName::__getFileName()), ]); } @@ -229,6 +194,26 @@ final class TeamCity extends DefaultResultPrinter ]); } + /** + * Verify that the given test suite is a valid Pest suite. + * + * @param TestSuite $suite + */ + private static function isPestTestSuite(TestSuite $suite): bool + { + return strncmp($suite->getName(), 'P\\', strlen('P\\')) === 0; + } + + /** + * Determine if the test suite is made up of multiple smaller test suites. + * + * @param TestSuite $suite + */ + private static function isCompoundTestSuite(TestSuite $suite): bool + { + return file_exists($suite->getName()) || !method_exists($suite->getName(), '__getFileName'); + } + public static function isPestTest(Test $test): bool { /** @var array $uses */ @@ -248,17 +233,10 @@ final class TeamCity extends DefaultResultPrinter ]); if (!$this->lastTestFailed) { - $this->writePestTestOutput($test->getName(), 'fg-green, bold', '✓'); - } - - $this->writeNewLine(); - - if ($test instanceof TestCase) { - $this->numAssertions += $test->getNumAssertions(); - } elseif ($test instanceof PhptTestCase) { - $this->numAssertions++; + $this->writeSuccess($test->getName()); } + $this->numAssertions += $test instanceof TestCase ? $test->getNumAssertions() : 1; $this->lastTestFailed = false; } @@ -267,100 +245,51 @@ final class TeamCity extends DefaultResultPrinter return (int) round($time * 1000); } - private function writePestTestOutput(string $message, string $color, string $symbol, string $suffix = null): void - { - $this->writeProgressWithColor($color, "$symbol "); - $this->writeProgress($message); - - if ($suffix !== null && strlen($suffix) > 0) { - $suffix = str_replace("\n", ' ', $suffix); - $this->writeWithColor($color, " -> $suffix"); - } - } - - /** - * @param Test|Testable $test - */ public function addError(Test $test, Throwable $t, float $time): void { - $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - - $this->removePestFromStackTrace($t); + $this->markAsFailure($t); + $this->writeError($test->getName()); $this->phpunitTeamCity->addError($test, $t, $time); } public function addFailure(Test $test, AssertionFailedError $e, float $time): void { - $this->lastTestFailed = true; - $this->writePestTestOutput($test->getName(), 'fg-red, bold', '⨯'); - - $this->removePestFromStackTrace($e); + $this->markAsFailure($e); + $this->writeError($test->getName()); $this->phpunitTeamCity->addFailure($test, $e, $time); } - private function removePestFromStackTrace(Throwable $e): void - { - if (!property_exists($e, 'serializableTrace')) { - return; - } - - $property = new ReflectionProperty($e, 'serializableTrace'); - $property->setAccessible(true); - $trace = $property->getValue($e); - - $cleanedTrace = []; - foreach ($trace as $item) { - if (key_exists('file', $item) && mb_strpos($item['file'], 'vendor/pestphp/pest/') > 0) { - continue; - } - - $cleanedTrace[] = $item; - } - - $property->setValue($e, $cleanedTrace); - } - - /** - * @phpstan-ignore-next-line - * - * @param Test|Testable $test - */ public function addWarning(Test $test, Warning $e, float $time): void { - $this->lastTestFailed = true; - - $this->removePestFromStackTrace($e); - $this->writeWarning($test, $e); - } - - private function writeWarning(Test $test, Throwable $t): void - { - $this->writePestTestOutput($test->getName(), 'fg-yellow, bold', '-', $t->getMessage()); + $this->markAsFailure($e); + $this->writeWarning($test->getName()); + $this->phpunitTeamCity->addWarning($test, $e, $time); } public function addIncompleteTest(Test $test, Throwable $t, float $time): void { - $this->lastTestFailed = true; - - $this->removePestFromStackTrace($t); - $this->writeWarning($test, $t); + $this->markAsFailure($t); + $this->writeWarning($test->getName()); + $this->phpunitTeamCity->addIncompleteTest($test, $t, $time); } public function addRiskyTest(Test $test, Throwable $t, float $time): void { - $this->lastTestFailed = true; - - $this->removePestFromStackTrace($t); - $this->writeWarning($test, $t); + $this->markAsFailure($t); + $this->writeWarning($test->getName()); + $this->phpunitTeamCity->addRiskyTest($test, $t, $time); } public function addSkippedTest(Test $test, Throwable $t, float $time): void { - $this->lastTestFailed = true; + $this->markAsFailure($t); + $this->writeWarning($test->getName()); + $this->phpunitTeamCity->addSkippedTest($test, $t, $time); + } - $this->removePestFromStackTrace($t); - $this->writeWarning($test, $t); - $this->phpunitTeamCity->printIgnoredTest($test->getName(), $t, $time); + private function markAsFailure(Throwable $t): void + { + $this->lastTestFailed = true; + ExceptionTrace::removePestReferences($t); } } diff --git a/src/Support/ExceptionTrace.php b/src/Support/ExceptionTrace.php index 014b88df..ec17afc8 100644 --- a/src/Support/ExceptionTrace.php +++ b/src/Support/ExceptionTrace.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Pest\Support; use Closure; +use ReflectionProperty; use Throwable; /** @@ -36,4 +37,30 @@ final class ExceptionTrace throw $throwable; } } + + /** + * Removes any item from the stack trace referencing Pest so as not to + * crowd the error log for the end user. + */ + public static function removePestReferences(Throwable $t): void + { + if (!property_exists($t, 'serializableTrace')) { + return; + } + + $property = new ReflectionProperty($t, 'serializableTrace'); + $property->setAccessible(true); + $trace = $property->getValue($t); + + $cleanedTrace = []; + foreach ($trace as $item) { + if (key_exists('file', $item) && mb_strpos($item['file'], 'vendor/pestphp/pest/') > 0) { + continue; + } + + $cleanedTrace[] = $item; + } + + $property->setValue($t, $cleanedTrace); + } } From a0637d86ffd54a0c7b838efb475b9cc9fe1aa371 Mon Sep 17 00:00:00 2001 From: luke Date: Sun, 1 Aug 2021 17:00:01 +0100 Subject: [PATCH 28/39] Refactors --- src/Logging/TeamCity.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Logging/TeamCity.php b/src/Logging/TeamCity.php index 9b7936cb..a9363b43 100644 --- a/src/Logging/TeamCity.php +++ b/src/Logging/TeamCity.php @@ -31,6 +31,8 @@ final class TeamCity extends DefaultResultPrinter private const TEST_SUITE_STARTED = 'testSuiteStarted'; private const TEST_SUITE_FINISHED = 'testSuiteFinished'; private const TEST_COUNT = 'testCount'; + private const TEST_STARTED = 'testStarted'; + private const TEST_FINISHED = 'testFinished'; /** @var int */ private $flowId; @@ -187,7 +189,7 @@ final class TeamCity extends DefaultResultPrinter return; } - $this->printEvent('testStarted', [ + $this->printEvent(self::TEST_STARTED, [ self::NAME => $test->getName(), // @phpstan-ignore-next-line self::LOCATION_HINT => self::PROTOCOL . $test->toString(), @@ -227,7 +229,7 @@ final class TeamCity extends DefaultResultPrinter */ public function endTest(Test $test, float $time): void { - $this->printEvent('testFinished', [ + $this->printEvent(self::TEST_FINISHED, [ self::NAME => $test->getName(), self::DURATION => self::toMilliseconds($time), ]); From 715f8b420b14027676a8fa531c2ee32e883ecaff Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:41:23 +0100 Subject: [PATCH 29/39] Updates phpunit dependency version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d3feddb8..9a3960f9 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": "^7.3 || ^8.0", "nunomaduro/collision": "^5.4.0", "pestphp/pest-plugin": "^1.0.0", - "phpunit/phpunit": "^9.3.7" + "phpunit/phpunit": "^9.5.5" }, "autoload": { "psr-4": { From 50e2d100295ccda42c1c3f2f7c4db1fc2d5f056f Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:50:28 +0100 Subject: [PATCH 30/39] docs: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b05a97d..488682df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [v1.13.0 (2021-07-28)](https://github.com/pestphp/pest/compare/v1.12.0...v1.13.0) ### Added +- A cleaner output when running the Pest runner in PhpStorm ([#350](https://github.com/pestphp/pest/pull/350)) - `toBeIn` expectation ([#363](https://github.com/pestphp/pest/pull/363)) ### Fixed From 4b236bf9ff21b65bfc949dde1862a3d04bd6eef0 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:50:44 +0100 Subject: [PATCH 31/39] docs: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 488682df..b63a6eae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [v1.13.0 (2021-07-28)](https://github.com/pestphp/pest/compare/v1.12.0...v1.13.0) +## [v1.13.0 (2021-08-02)](https://github.com/pestphp/pest/compare/v1.12.0...v1.13.0) ### Added - A cleaner output when running the Pest runner in PhpStorm ([#350](https://github.com/pestphp/pest/pull/350)) - `toBeIn` expectation ([#363](https://github.com/pestphp/pest/pull/363)) From 475279a4fa84efe415d5c9d0c97154f44bc7c739 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:56:29 +0100 Subject: [PATCH 32/39] Adds continue-on-error for php 8.1 --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0151ddd3..e3e31b16 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,10 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] php: ['7.3', '7.4', '8.0', '8.1'] dependency-version: [prefer-lowest, prefer-stable] + include: + os: '8.1' + continue-on-error: true + continue-on-error: ${{matrix.continue-on-error}} name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 172b69cf15d263429e56dabc6e5e3668f4638f6a Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:57:57 +0100 Subject: [PATCH 33/39] Adds continue-on-error for php 8.1 --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e3e31b16..c6aee051 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,15 +5,15 @@ on: ['push', 'pull_request'] jobs: ci: runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.continue-on-error }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] php: ['7.3', '7.4', '8.0', '8.1'] dependency-version: [prefer-lowest, prefer-stable] - include: - os: '8.1' - continue-on-error: true - continue-on-error: ${{matrix.continue-on-error}} + include: + - os: '8.1' + continue-on-error: true name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 8e289b7a7d3ead5cfbb357aaaced98ea4d21cc6e Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 12:59:07 +0100 Subject: [PATCH 34/39] Adds continue-on-error for php 8.1 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c6aee051..4b32d726 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: php: ['7.3', '7.4', '8.0', '8.1'] dependency-version: [prefer-lowest, prefer-stable] include: - - os: '8.1' + - php: '8.1' continue-on-error: true name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 524457a4e6d6d1dbf5fdb7ec239dd966d037cc09 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 13:00:07 +0100 Subject: [PATCH 35/39] Adds continue-on-error for php 8.1 --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4b32d726..55c2b439 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,6 +11,7 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] php: ['7.3', '7.4', '8.0', '8.1'] dependency-version: [prefer-lowest, prefer-stable] + continue-on-error: [false] include: - php: '8.1' continue-on-error: true From eed221af4684f8bec102ddfe05f0f88edeeae528 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 13:03:13 +0100 Subject: [PATCH 36/39] Adds continue-on-error for php 8.1 --- .github/workflows/tests.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 55c2b439..62c0ecd0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,16 +5,17 @@ on: ['push', 'pull_request'] jobs: ci: runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.continue-on-error }} + continue-on-error: ${{ matrix.experimental }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - php: ['7.3', '7.4', '8.0', '8.1'] + php: ['7.3', '7.4', '8.0'] dependency-version: [prefer-lowest, prefer-stable] - continue-on-error: [false] + experimental: [false] include: - php: '8.1' - continue-on-error: true + os: [ubuntu-latest, macos-latest, windows-latest] + experimental: true name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From f6f8140ebc53cd2a92c439d16791ec66dbd103a1 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 13:05:29 +0100 Subject: [PATCH 37/39] Splits 8.1 OS jobs --- .github/workflows/tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 62c0ecd0..ac62f23a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,8 +14,14 @@ jobs: experimental: [false] include: - php: '8.1' - os: [ubuntu-latest, macos-latest, windows-latest] + os: ubuntu-latest experimental: true + - php: '8.1' + os: macos-latest + experimental: true + - php: '8.1' + os: windows-latest + experimental: true name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 79de0d58752ebe2d3b6a6249e4728df57a9d2627 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 13:05:55 +0100 Subject: [PATCH 38/39] Splits 8.1 OS jobs --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac62f23a..10dfcc38 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,11 +17,11 @@ jobs: os: ubuntu-latest experimental: true - php: '8.1' - os: macos-latest - experimental: true + os: macos-latest + experimental: true - php: '8.1' - os: windows-latest - experimental: true + os: windows-latest + experimental: true name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From e56e8186595f767ab9daa7713346d6079090e4c4 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 2 Aug 2021 13:06:41 +0100 Subject: [PATCH 39/39] Splits 8.1 OS jobs --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 10dfcc38..d0ca6965 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,12 +16,15 @@ jobs: - php: '8.1' os: ubuntu-latest experimental: true + dependency-version: prefer-stable - php: '8.1' os: macos-latest experimental: true + dependency-version: prefer-stable - php: '8.1' os: windows-latest experimental: true + dependency-version: prefer-stable name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }}