Skip to content

Commit

Permalink
Print 100% ending progress (#524)
Browse files Browse the repository at this point in the history
* Print 100% ending progress

* Fix for CC bug
  • Loading branch information
Slamdunk committed Aug 27, 2020
1 parent e54bea9 commit 79d788b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/Runners/PHPUnit/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use function rtrim;
use function sprintf;
use function str_pad;
use function str_repeat;
use function strlen;

use const DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -205,7 +206,7 @@ public function getHeader(): string
{
$resourceUsage = (new ResourceUsageFormatter())->resourceUsageSinceStartOfRequest();

return "\n\n" . $resourceUsage . "\n\n";
return "\n" . $resourceUsage . "\n\n";
}

/**
Expand Down Expand Up @@ -364,10 +365,18 @@ private function printFeedbackItem(string $item): void
$this->printFeedbackItemColor($item);
++$this->column;
++$this->casesProcessed;
if ($this->column !== $this->maxColumn) {
if ($this->column !== $this->maxColumn && $this->casesProcessed < $this->totalCases) {
return;
}

if (
$this->casesProcessed > 0
&& $this->casesProcessed === $this->totalCases
&& ($pad = $this->maxColumn - $this->column) > 0
) {
$this->output->write(str_repeat(' ', $pad));
}

$this->output->write($this->getProgress());
$this->println();
}
Expand Down
9 changes: 7 additions & 2 deletions test/Unit/Runners/PHPUnit/ResultPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use function defined;
use function file_put_contents;
use function sprintf;
use function str_repeat;
use function uniqid;

/**
Expand Down Expand Up @@ -159,7 +160,7 @@ public function testGetHeader(): void
$header = $this->printer->getHeader();

static::assertMatchesRegularExpression(
"/\n\nTime: ([.:]?[0-9]{1,3})+ ?" .
"/\nTime: ([.:]?[0-9]{1,3})+ ?" .
'(minute|minutes|second|seconds|ms|)?,' .
" Memory:[\\s][0-9]+([.][0-9]{1,2})? ?M[Bb]\n\n/",
$header
Expand Down Expand Up @@ -287,7 +288,7 @@ public function testPrintFeedbackForMixed(): void
$this->printer->addTest($this->mixedSuite);
$this->printer->printFeedback($this->mixedSuite);
$contents = $this->output->fetch();
static::assertSame('.F..E.F.WSSR.F.WSSR', $contents);
static::assertSame(".F..E.F.WSSR.F.WSSR 19 / 19 (100%)\n", $contents);
}

public function testPrintFeedbackForMoreThan100Suites(): void
Expand Down Expand Up @@ -324,6 +325,8 @@ public function testPrintFeedbackForMoreThan100Suites(): void
$expected .= '.';
}

$expected .= sprintf("%s 120 / 120 (100%%)\n", str_repeat(' ', $firstRowColumns - $secondRowColumns));

static::assertSame($expected, $feedback);
}

Expand Down Expand Up @@ -361,6 +364,8 @@ public function testResultPrinterAdjustsTotalCountForDataProviders(): void
$expected .= '.';
}

$expected .= sprintf("%s 66 / 66 (100%%)\n", str_repeat(' ', $firstRowColumns - $secondRowColumns));

static::assertSame($expected, $feedback);
}

Expand Down
5 changes: 4 additions & 1 deletion test/fixtures/phpunit-fully-configured.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
<file>./passing_tests/GroupsTest.php</file>
</testsuite>
</testsuites>
<!--
processUncoveredFiles="true" omitted due to
https://github.com/sebastianbergmann/php-code-coverage/issues/801
-->
<coverage includeUncoveredFiles="true"
processUncoveredFiles="true"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="true">
<include>
Expand Down

0 comments on commit 79d788b

Please sign in to comment.