diff --git a/infection.json5 b/infection.json5 index 9426b75..57864a2 100644 --- a/infection.json5 +++ b/infection.json5 @@ -39,7 +39,9 @@ "Coalesce": { "ignore": [ // Cannot test this case. - "Fidry\\CpuCoreCounter\\CpuCoreCounter::getAvailableForParallelisation" + "Fidry\\CpuCoreCounter\\CpuCoreCounter::getAvailableForParallelisation", + // Not interested in testing this case. + "Fidry\\CpuCoreCounter\\Finder\\ProcOpenBasedFinder::diagnose" ] }, "Continue_": false, diff --git a/src/Finder/CpuInfoFinder.php b/src/Finder/CpuInfoFinder.php index dea4c41..8013877 100644 --- a/src/Finder/CpuInfoFinder.php +++ b/src/Finder/CpuInfoFinder.php @@ -49,10 +49,12 @@ public function diagnose(): string } return sprintf( - 'Found the file "%s" with the content:%s%s', + 'Found the file "%s" with the content:%s%s%sWill return "%s".', self::CPU_INFO_PATH, PHP_EOL, - $cpuInfo + $cpuInfo, + PHP_EOL, + self::countCpuCores($cpuInfo) ); } diff --git a/src/Finder/ProcOpenBasedFinder.php b/src/Finder/ProcOpenBasedFinder.php index 793ec64..4d51f89 100644 --- a/src/Finder/ProcOpenBasedFinder.php +++ b/src/Finder/ProcOpenBasedFinder.php @@ -56,16 +56,19 @@ public function diagnose(): string return $failed ? sprintf( - 'Executed the command "%s" which wrote the following output to the STDERR:%s%s', + 'Executed the command "%s" which wrote the following output to the STDERR:%s%s%sWill return "null".', $command, PHP_EOL, - $stderr + $stderr, + PHP_EOL ) : sprintf( - 'Executed the command "%s" and got the following (STDOUT) output:%s%s', + 'Executed the command "%s" and got the following (STDOUT) output:%s%s%sWill return "%s".', $command, PHP_EOL, - $stdout + $stdout, + PHP_EOL, + $this->countCpuCores($stdout) ?? 'null' ); } diff --git a/tests/Finder/ProcOpenBasedFinderTestCase.php b/tests/Finder/ProcOpenBasedFinderTestCase.php index a0a79ba..0801708 100644 --- a/tests/Finder/ProcOpenBasedFinderTestCase.php +++ b/tests/Finder/ProcOpenBasedFinderTestCase.php @@ -63,8 +63,8 @@ public function test_it_can_do_a_diagnosis( public static function diagnosisProvider(): iterable { - $stdoutResultRegex = '/^Executed the command ".*" and got the following \(STDOUT\) output:\nsmth in stdout$/'; - $stderrResultRegex = '/^Executed the command ".*" which wrote the following output to the STDERR:\nsmth in stderr$/'; + $stdoutResultRegex = '/^Executed the command ".*" and got the following \(STDOUT\) output:\nsmth in stdout\nWill return "(null|\d)"\.$/'; + $stderrResultRegex = '/^Executed the command ".*" which wrote the following output to the STDERR:\nsmth in stderr\nWill return "(null|\d)"\.$/'; yield 'could not execute command' => [ null,