Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix teamcity output concurrency #851

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/WrapperRunner/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,13 @@ public function start(): void
$output->write("\n");
}

/** @param list<SplFileInfo> $teamcityFiles */
public function printFeedback(
SplFileInfo $progressFile,
SplFileInfo $outputFile,
array $teamcityFiles
SplFileInfo|null $teamcityFile
): void {
if ($this->options->needsTeamcity) {
$teamcityProgress = $this->tailMultiple($teamcityFiles);
if ($this->options->needsTeamcity && $teamcityFile !== null) {
$teamcityProgress = $this->tailMultiple([$teamcityFile]);

if ($this->teamcityLogFileHandle !== null) {
fwrite($this->teamcityLogFileHandle, $teamcityProgress);
Expand Down
2 changes: 1 addition & 1 deletion src/WrapperRunner/WrapperRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private function flushWorker(WrapperWorker $worker): void
$this->printer->printFeedback(
$worker->progressFile,
$worker->unexpectedOutputFile,
$this->teamcityFiles,
$worker->teamcityFile ?? null,
);
$worker->reset();
}
Expand Down
18 changes: 9 additions & 9 deletions test/Unit/WrapperRunner/ResultPrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ public function testPrintFeedbackForMixed(): void
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'output1';
file_put_contents($feedbackFile, 'EWWFFFRRSSSS.......');
touch($outputFile);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$contents = $this->output->fetch();
self::assertSame('EWWFFFRRSSSS.......', $contents);

$feedbackFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'feedback2';
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'output2';
file_put_contents($feedbackFile, 'E');
touch($outputFile);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$contents = $this->output->fetch();
self::assertSame("E 20 / 20 (100%)\n", $contents);
}
Expand All @@ -159,7 +159,7 @@ public function testColorsForFailing(): void
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'output1';
file_put_contents($feedbackFile, 'E');
touch($outputFile);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$contents = $this->output->fetch();
self::assertStringContainsString('E', $contents);
self::assertStringContainsString('31;1', $contents);
Expand All @@ -181,7 +181,7 @@ public function testTeamcityFeedbackOnFile(): void
file_put_contents($feedbackFile, 'E');
touch($outputFile);

$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), [new SplFileInfo($teamcitySource)]);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), new SplFileInfo($teamcitySource));

self::assertSame('E', $this->output->fetch());
self::assertFileExists($teamcityLog);
Expand All @@ -207,7 +207,7 @@ public function testTeamcityFeedbackOnStdout(): void
file_put_contents($feedbackFile, 'E');
touch($outputFile);

$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), [new SplFileInfo($teamcitySource)]);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), new SplFileInfo($teamcitySource));
$this->printer->printResults($this->getEmptyTestResult(), [new SplFileInfo($teamcitySource)], []);

self::assertSame($teamcitySourceContent, $this->output->fetch());
Expand All @@ -228,7 +228,7 @@ public function testTestdoxOutputWithProgress(): void
file_put_contents($feedbackFile, 'EEE');
touch($outputFile);

$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$this->printer->printResults($this->getEmptyTestResult(), [], [new SplFileInfo($testdoxSource)]);

self::assertStringMatchesFormat(
Expand All @@ -252,7 +252,7 @@ public function testTestdoxOutputWithoutProgress(): void
file_put_contents($feedbackFile, 'EEE');
touch($outputFile);

$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$this->printer->printResults($this->getEmptyTestResult(), [], [new SplFileInfo($testdoxSource)]);

self::assertStringMatchesFormat(
Expand All @@ -279,7 +279,7 @@ public function testPrintFeedbackFromMultilineSource(): void
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'output1';
file_put_contents($feedbackFile, str_repeat('.', 300));
touch($outputFile);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$contents = $this->output->fetch();
self::assertSame($expected, $contents);
}
Expand Down Expand Up @@ -338,7 +338,7 @@ public function testPrintFeedbackFromMultilineSource2(): void
$outputFile = $this->tmpDir . DIRECTORY_SEPARATOR . 'output1';
file_put_contents($feedbackFile, str_repeat('.', 2484));
touch($outputFile);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), []);
$this->printer->printFeedback(new SplFileInfo($feedbackFile), new SplFileInfo($outputFile), null);
$contents = $this->output->fetch();
self::assertSame($expected, $contents);
}
Expand Down
Loading