Skip to content

Commit

Permalink
Tests: performance improvement
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Mar 4, 2024
1 parent e460a85 commit 57b32ef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Tests/IOTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace PHPCSDevTools\Tests;

use RuntimeException;
use Yoast\PHPUnitPolyfills\TestCases\XTestCase;

/**
Expand Down Expand Up @@ -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.');
}
Expand Down

0 comments on commit 57b32ef

Please sign in to comment.