Add Initial teamcity support

This commit is contained in:
Oliver
2023-01-08 11:21:08 +01:00
parent 15931e2418
commit 0839c7e127
36 changed files with 1087 additions and 78 deletions

View File

@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Pest\Subscribers;
use Pest\Logging\TeamCity\Converter;
use Pest\Logging\TeamCity\TeamCityLogger;
use Pest\TestSuite;
use PHPUnit\Event\TestRunner\Configured;
use PHPUnit\Event\TestRunner\ConfiguredSubscriber;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* @internal
*/
final class EnsureTeamCityEnabled implements ConfiguredSubscriber
{
public function __construct(
private readonly OutputInterface $output,
private readonly InputInterface $input,
private readonly TestSuite $testSuite,
) {
}
/**
* Runs the subscriber.
*/
public function notify(Configured $event): void
{
if (! $this->input->hasParameterOption('--teamcity')) {
return;
}
$flowId = getenv('FLOW_ID');
$flowId = is_string($flowId) ? (int) $flowId : getmypid();
new TeamCityLogger(
$this->output,
new Converter($this->testSuite->rootPath),
$flowId === false ? null : $flowId,
getenv('COLLISION_IGNORE_DURATION') !== false
);
}
}