Skip to content

Commit

Permalink
CLI-1336: Fix mutation timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed May 16, 2024
1 parent 90fd815 commit 74d7163
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion infection.json5
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"mutators": {
"@default": true
},
"timeout": 300,
"timeout": 30,
"testFrameworkOptions": "--exclude-group=serial"
}
4 changes: 3 additions & 1 deletion src/Command/Api/ApiCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,14 @@ private function isApiSpecChecksumCacheValid(\Symfony\Component\Cache\CacheItem
}

/**
* Breaking caching during tests will cause performance issues and timeouts.
*
* @return array<mixed>
* @infection-ignore-all
*/
private function getCloudApiSpec(string $specFilePath): array {
$cacheKey = basename($specFilePath);
$cache = new PhpArrayAdapter(__DIR__ . '/../../../var/cache/' . $cacheKey . '.cache', new NullAdapter());
// @infection-ignore-all
$cacheItemChecksum = $cache->getItem($cacheKey . '.checksum');
$cacheItemSpec = $cache->getItem($cacheKey);

Expand Down
3 changes: 3 additions & 0 deletions src/Helpers/LocalMachineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,15 @@ public function isBrowserAvailable(): bool {
/**
* Starts a background browser/tab for the current site or a specified URL.
*
* Exclude from mutation testing as we don't want real browser windows opened.
*
* @param string|null $uri Optional URI or site path to open in browser. If omitted, or if a site path
* is specified, the current site home page uri will be prepended if the site's
* hostname resolves.
* @param string|null $browser The command to run to launch a browser.
* @return bool TRUE if browser was opened. FALSE if browser was disabled by the user or a
* default browser could not be found.
* @infection-ignore-all
*/
public function startBrowser(string $uri = NULL, string $browser = NULL): bool {
// We can only open a browser if we have a DISPLAY environment variable on
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/src/Commands/Api/ApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,8 @@ public function providerTestApiCommandDefinitionParameters(): array {

/**
* @dataProvider providerTestApiCommandDefinitionParameters
* @param $useSpecCache
* @param $commandName
* @param $method
* @param $usage
*/
public function testApiCommandDefinitionParameters(mixed $useSpecCache, mixed $commandName, mixed $method, mixed $usage): void {
public function testApiCommandDefinitionParameters(string $useSpecCache, string $commandName, string $method, string $usage): void {
putenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE=' . $useSpecCache);

$this->command = $this->getApiCommandByName($commandName);
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/DocsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function createCommand(): CommandBase {
/**
* @dataProvider providerTestDocsCommand
*/
public function testDocsCommand(mixed $input, mixed $expectedOutput): void {
public function testDocsCommand(int $input, string $expectedOutput): void {
$localMachineHelper = $this->mockLocalMachineHelper();
$localMachineHelper->startBrowser(Argument::any())->shouldBeCalled();

Expand Down

0 comments on commit 74d7163

Please sign in to comment.