Skip to content

Commit

Permalink
Fix progress detection with single digit percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Slamdunk committed Feb 13, 2023
1 parent e8e95e5 commit 09cfc72
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ ifeq ($(strip $(LOCAL_BASE_BRANCH)),)
endif
BASE_BRANCH ?= $(LOCAL_BASE_BRANCH)

#all: csfix static-analysis code-coverage
all: csfix static-analysis test
all: csfix static-analysis code-coverage
@echo "Done."

vendor: composer.json
Expand Down
2 changes: 1 addition & 1 deletion src/WrapperRunner/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function printFeedback(SplFileInfo $progressFile, array $teamcityFiles):
return;
}

$feedbackItems = preg_replace('/ +\\d+ \\/ \\d+ \\( ?\\d+%\\)\\s*/', '', $feedbackItems);
$feedbackItems = preg_replace('/ +\\d+ \\/ \\d+ \\( *\\d+%\\)\\s*/', '', $feedbackItems);
assert($feedbackItems !== null);

$actualTestCount = strlen($feedbackItems);
Expand Down
86 changes: 86 additions & 0 deletions test/Unit/WrapperRunner/ResultPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,92 @@ public function testPrintFeedbackFromMultilineSource(): void
self::assertSame($source, $contents);
}

public function testPrintFeedbackFromMultilineSource2(): void
{
$source = <<<'EOF'
..................................................................................................... 101 / 2484 ( 4%)
..................................................................................................... 202 / 2484 ( 8%)
..................................................................................................... 303 / 2484 ( 12%)
..................................................................................................... 404 / 2484 ( 16%)
..................................................................................................... 505 / 2484 ( 20%)
..................................................................................................... 606 / 2484 ( 24%)
..................................................................................................... 707 / 2484 ( 28%)
..................................................................................................... 808 / 2484 ( 32%)
..................................................................................................... 909 / 2484 ( 36%)
..................................................................................................... 1010 / 2484 ( 40%)
..................................................................................................... 1111 / 2484 ( 44%)
..................................................................................................... 1212 / 2484 ( 48%)
..................................................................................................... 1313 / 2484 ( 52%)
..................................................................................................... 1414 / 2484 ( 56%)
..................................................................................................... 1515 / 2484 ( 60%)
..................................................................................................... 1616 / 2484 ( 65%)
..................................................................................................... 1717 / 2484 ( 69%)
..................................................................................................... 1818 / 2484 ( 73%)
..................................................................................................... 1919 / 2484 ( 77%)
..................................................................................................... 2020 / 2484 ( 81%)
..................................................................................................... 2121 / 2484 ( 85%)
..................................................................................................... 2222 / 2484 ( 89%)
..................................................................................................... 2323 / 2484 ( 93%)
..................................................................................................... 2424 / 2484 ( 97%)
............................................................ 2484 / 2484 (100%)

EOF;

$expected = <<<'EOF'
............................................................. 61 / 2484 ( 2%)
............................................................. 122 / 2484 ( 4%)
............................................................. 183 / 2484 ( 7%)
............................................................. 244 / 2484 ( 9%)
............................................................. 305 / 2484 ( 12%)
............................................................. 366 / 2484 ( 14%)
............................................................. 427 / 2484 ( 17%)
............................................................. 488 / 2484 ( 19%)
............................................................. 549 / 2484 ( 22%)
............................................................. 610 / 2484 ( 24%)
............................................................. 671 / 2484 ( 27%)
............................................................. 732 / 2484 ( 29%)
............................................................. 793 / 2484 ( 31%)
............................................................. 854 / 2484 ( 34%)
............................................................. 915 / 2484 ( 36%)
............................................................. 976 / 2484 ( 39%)
............................................................. 1037 / 2484 ( 41%)
............................................................. 1098 / 2484 ( 44%)
............................................................. 1159 / 2484 ( 46%)
............................................................. 1220 / 2484 ( 49%)
............................................................. 1281 / 2484 ( 51%)
............................................................. 1342 / 2484 ( 54%)
............................................................. 1403 / 2484 ( 56%)
............................................................. 1464 / 2484 ( 58%)
............................................................. 1525 / 2484 ( 61%)
............................................................. 1586 / 2484 ( 63%)
............................................................. 1647 / 2484 ( 66%)
............................................................. 1708 / 2484 ( 68%)
............................................................. 1769 / 2484 ( 71%)
............................................................. 1830 / 2484 ( 73%)
............................................................. 1891 / 2484 ( 76%)
............................................................. 1952 / 2484 ( 78%)
............................................................. 2013 / 2484 ( 81%)
............................................................. 2074 / 2484 ( 83%)
............................................................. 2135 / 2484 ( 85%)
............................................................. 2196 / 2484 ( 88%)
............................................................. 2257 / 2484 ( 90%)
............................................................. 2318 / 2484 ( 93%)
............................................................. 2379 / 2484 ( 95%)
............................................................. 2440 / 2484 ( 98%)
............................................ 2484 / 2484 (100%)

EOF;

$this->printer->setTestCount(2484);
$this->printer->start();
$this->output->fetch();
$feedbackFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'feedback1';
file_put_contents($feedbackFile, $source);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), []);
$contents = $this->output->fetch();
self::assertSame($expected, $contents);
}

private function getStartOutput(): string
{
$this->printer->start();
Expand Down

0 comments on commit 09cfc72

Please sign in to comment.