Skip to content

Commit

Permalink
Fix --functional progress output (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
ax-ml authored Feb 19, 2024
1 parent 8b3e4a4 commit cf4e141
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"phpunit/php-code-coverage": "^10.1.11 || ^11.0.0",
"phpunit/php-file-iterator": "^4.1.0 || ^5.0.0",
"phpunit/php-timer": "^6.0.0 || ^7.0.0",
"phpunit/phpunit": "^10.5.9 || ^11.0.2",
"phpunit/phpunit": "^10.5.9 || ^11.0.3",
"sebastian/environment": "^6.0.1 || ^7.0.0",
"symfony/console": "^6.4.3 || ^7.0.3",
"symfony/process": "^6.4.3 || ^7.0.3"
Expand Down
11 changes: 8 additions & 3 deletions src/WrapperRunner/SuiteLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use function mt_srand;
use function ob_get_clean;
use function ob_start;
use function sprintf;
use function str_starts_with;
use function strlen;
use function substr;
Expand Down Expand Up @@ -85,10 +86,14 @@ public function __construct(
$name = $test->name();
if ($test->providedData() !== []) {
$dataName = $test->dataName();
if (is_int($dataName)) {
$name .= '#' . $dataName;
if ($this->options->functional) {
$name = sprintf('/%s\s.*%s.*$/', $name, $dataName);
} else {
$name .= '@' . $dataName;
if (is_int($dataName)) {
$name .= '#' . $dataName;
} else {
$name .= '@' . $dataName;
}
}
}

Expand Down
26 changes: 24 additions & 2 deletions test/Unit/WrapperRunner/WrapperRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,18 @@ public function testFunctionalParallelization(): void
$this->bareOptions['--functional'] = true;

$runnerResult = $this->runRunner();
self::assertStringContainsString('.......', $runnerResult->output);

$expectedOutput = <<<'EOF'
Processes: 2
Runtime: PHP %s
.......... 10 / 10 (100%)
Time: %s, Memory: %s MB
OK%a
EOF;
self::assertStringMatchesFormat($expectedOutput, $runnerResult->output);
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

Expand All @@ -649,7 +660,18 @@ public function testFunctionalParallelizationWithJunitLogging(): void
$this->bareOptions['--log-junit'] = $outputFile;

$runnerResult = $this->runRunner();
self::assertStringContainsString('.......', $runnerResult->output);

$expectedOutput = <<<'EOF'
Processes: 1
Runtime: PHP %s
.......... 10 / 10 (100%)
Time: %s, Memory: %s MB
OK%a
EOF;
self::assertStringMatchesFormat($expectedOutput, $runnerResult->output);
self::assertSame(RunnerInterface::SUCCESS_EXIT, $runnerResult->exitCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public function testDataProvider2(string $a, string $b): void
{
self::assertEquals($a, $b);
}

#[DataProvider('dataProvider2')]
public function testDataProvider2SameBeginningOfName(string $a, string $b): void
{
self::assertEquals($a, $b);
}
}

0 comments on commit cf4e141

Please sign in to comment.