From 57b32ef354eb79a0f8230f0a8eb6f18e4874caf1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 4 Mar 2024 06:16:00 +0100 Subject: [PATCH] Tests: performance improvement Bypassing the Windows Cmd shell should make running these tests significantly faster on Windows. Includes fixing a potential fatal in the tests due to a missing `use` statement for the `RuntimeException` class. --- Tests/IOTestCase.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tests/IOTestCase.php b/Tests/IOTestCase.php index c16e407..a538376 100644 --- a/Tests/IOTestCase.php +++ b/Tests/IOTestCase.php @@ -10,6 +10,7 @@ namespace PHPCSDevTools\Tests; +use RuntimeException; use Yoast\PHPUnitPolyfills\TestCases\XTestCase; /** @@ -51,8 +52,12 @@ protected function executeCliCommand($command, $workingDir = null) 2 => ['pipe', 'w'], // stderr ]; - $process = \proc_open($command, $descriptorspec, $pipes, $workingDir); + $options = null; + if (stripos(PHP_OS, 'WIN') === 0) { + $options = ['bypass_shell' => true]; + } + $process = \proc_open($command, $descriptorspec, $pipes, $workingDir, null, $options); if (\is_resource($process) === false) { throw new RuntimeException('Could not obtain a resource with proc_open() to execute the command.'); }