Skip to content

Commit

Permalink
Allow fractional values for timeout (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanmai committed Aug 25, 2020
1 parent d6c80c9 commit 5337aa3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions resources/schema.json
Expand Up @@ -7,9 +7,9 @@
],
"properties": {
"timeout": {
"type": "integer",
"type": "number",
"description": "The allowed timeout in seconds.",
"minimum": "1"
"minimum": "0"
},
"source": {
"type": "object",
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration/Configuration.php
Expand Up @@ -89,7 +89,7 @@ class Configuration
* @param array<string, Mutator> $mutators
*/
public function __construct(
int $timeout,
float $timeout,
array $sourceDirectories,
iterable $sourceFiles,
string $sourceFilesFilter,
Expand Down Expand Up @@ -117,7 +117,7 @@ public function __construct(
int $threadCount,
bool $dryRun
) {
Assert::nullOrGreaterThanEq($timeout, 1);
Assert::nullOrGreaterThanEq($timeout, 0);
Assert::allString($sourceDirectories);
Assert::allIsInstanceOf($mutators, Mutator::class);
Assert::oneOf($logVerbosity, self::LOG_VERBOSITY);
Expand Down Expand Up @@ -154,7 +154,7 @@ public function __construct(
$this->dryRun = $dryRun;
}

public function getProcessTimeout(): int
public function getProcessTimeout(): float
{
return $this->timeout;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration/Schema/SchemaConfiguration.php
Expand Up @@ -66,7 +66,7 @@ final class SchemaConfiguration
*/
public function __construct(
string $file,
?int $timeout,
?float $timeout,
Source $source,
Logs $logs,
?string $tmpDir,
Expand All @@ -80,7 +80,7 @@ public function __construct(
?string $initialTestsPhpOptions,
?string $testFrameworkExtraOptions
) {
Assert::nullOrGreaterThanEq($timeout, 1);
Assert::nullOrGreaterThanEq($timeout, 0);
Assert::nullOrOneOf($testFramework, TestFrameworkTypes::TYPES);

$this->file = $file;
Expand All @@ -104,7 +104,7 @@ public function getFile(): string
return $this->file;
}

public function getTimeout(): ?int
public function getTimeout(): ?float
{
return $this->timeout;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Configuration/ConfigurationAssertions.php
Expand Up @@ -55,7 +55,7 @@ trait ConfigurationAssertions
*/
private function assertConfigurationStateIs(
Configuration $configuration,
?int $expectedTimeout,
?float $expectedTimeout,
array $expectedSourceDirectories,
array $expectedSourceFiles,
string $expectedFilter,
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/Configuration/ConfigurationTest.php
Expand Up @@ -59,7 +59,7 @@ final class ConfigurationTest extends TestCase
* @param Mutator[] $mutators
*/
public function test_it_can_be_instantiated(
int $timeout,
float $timeout,
array $sourceDirectories,
array $sourceFiles,
string $sourceFileFilter,
Expand Down Expand Up @@ -152,7 +152,7 @@ public function test_it_can_be_instantiated(
public function valueProvider(): iterable
{
yield 'empty' => [
10,
10.,
[],
[],
'',
Expand Down Expand Up @@ -182,7 +182,7 @@ public function valueProvider(): iterable
];

yield 'nominal' => [
1,
1.,
['src', 'lib'],
[
new SplFileInfo('Foo.php', 'Foo.php', 'Foo.php'),
Expand Down
Expand Up @@ -49,7 +49,7 @@ final class SchemaConfigurationTest extends TestCase
*/
public function test_it_can_be_instantiated(
string $path,
?int $timeout,
?float $timeout,
Source $source,
Logs $logs,
?string $tmpDir,
Expand Down Expand Up @@ -117,7 +117,7 @@ public function valueProvider(): iterable

yield 'complete' => [
'/path/to/config',
10,
10.,
new Source(['src', 'lib'], ['fixtures', 'tests']),
new Logs(
'text.log',
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Configuration/Schema/SchemaValidatorTest.php
Expand Up @@ -98,7 +98,7 @@ public function configProvider(): iterable
<<<'ERROR'
"/path/to/config" does not match the expected JSON schema:
- [source] The property source is required
- [timeout] String value found, but an integer is required
- [timeout] String value found, but a number is required
ERROR
,
];
Expand Down

0 comments on commit 5337aa3

Please sign in to comment.