From bc050c8fe00f524ea68d28a6dc8348e6f7dd1664 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 18 Feb 2024 12:25:52 +0100 Subject: [PATCH 1/3] Make phpunit fail if a --filter does not execute any tests --- phpunit.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpunit.xml b/phpunit.xml index 03fcbf718f..b083450096 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,8 +4,10 @@ bootstrap="tests/bootstrap.php" cacheResult="false" colors="true" + executionOrder="random" failOnRisky="true" failOnWarning="true" + failOnEmptyTestSuite="true" beStrictAboutChangesToGlobalState="true" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" From a61d873b70acc71e9987698a0a1428afc62f433b Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 18 Feb 2024 12:38:28 +0100 Subject: [PATCH 2/3] run tests in isolation, as they depend on global state (ENV vars) --- .../PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php index 5232f164ff..76ca42c74e 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php @@ -13,6 +13,9 @@ use function sprintf; use const PHP_VERSION_ID; +/** + * @runTestsInSeparateProcesses + */ class TableErrorFormatterTest extends ErrorFormatterTestCase { From 3f02ee9d11edc16dc181da97acb399fa1cf552d1 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 18 Feb 2024 12:41:44 +0100 Subject: [PATCH 3/3] Update TableErrorFormatterTest.php --- .../Command/ErrorFormatter/TableErrorFormatterTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php index 76ca42c74e..5863760fef 100644 --- a/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php +++ b/tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php @@ -13,9 +13,6 @@ use function sprintf; use const PHP_VERSION_ID; -/** - * @runTestsInSeparateProcesses - */ class TableErrorFormatterTest extends ErrorFormatterTestCase { @@ -27,6 +24,7 @@ protected function setUp(): void protected function tearDown(): void { putenv('COLUMNS'); + putenv('TERM_PROGRAM'); } public function dataFormatterOutputProvider(): iterable @@ -198,6 +196,7 @@ public function testFormatErrors( } $formatter = $this->createErrorFormatter(null); + // NOTE: extra env vars need to be cleared in tearDown() foreach ($extraEnvVars as $envVar) { putenv($envVar); }