Skip to content

Commit 6efa21d

Browse files
Merge branch '11.5'
2 parents 9cbbc04 + 6321d41 commit 6efa21d

23 files changed

+314
-1
lines changed

src/Event/Emitter/DispatchingEmitter.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,24 @@ public function testRunnerTriggeredGarbageCollection(): void
261261
);
262262
}
263263

264+
public function testRunnerStartedChildProcess(): void
265+
{
266+
$this->dispatcher->dispatch(
267+
new TestRunner\ChildProcessStarted($this->telemetryInfo()),
268+
);
269+
}
270+
271+
public function testRunnerFinishedChildProcess(string $stdout, string $stderr): void
272+
{
273+
$this->dispatcher->dispatch(
274+
new TestRunner\ChildProcessFinished(
275+
$this->telemetryInfo(),
276+
$stdout,
277+
$stderr,
278+
),
279+
);
280+
}
281+
264282
/**
265283
* @throws InvalidArgumentException
266284
* @throws UnknownEventTypeException

src/Event/Emitter/Emitter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ public function testAfterLastTestMethodFinished(string $testClassName, ClassMeth
253253

254254
public function testSuiteFinished(TestSuite $testSuite): void;
255255

256+
public function testRunnerStartedChildProcess(): void;
257+
258+
public function testRunnerFinishedChildProcess(string $stdout, string $stderr): void;
259+
256260
public function testRunnerTriggeredDeprecation(string $message): void;
257261

258262
public function testRunnerTriggeredWarning(string $message): void;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\Event\TestRunner;
11+
12+
use PHPUnit\Event\Event;
13+
use PHPUnit\Event\Telemetry;
14+
15+
/**
16+
* @immutable
17+
*
18+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
19+
*/
20+
final readonly class ChildProcessFinished implements Event
21+
{
22+
private Telemetry\Info $telemetryInfo;
23+
private string $stdout;
24+
private string $stderr;
25+
26+
public function __construct(Telemetry\Info $telemetryInfo, string $stdout, string $stderr)
27+
{
28+
$this->telemetryInfo = $telemetryInfo;
29+
$this->stdout = $stdout;
30+
$this->stderr = $stderr;
31+
}
32+
33+
public function telemetryInfo(): Telemetry\Info
34+
{
35+
return $this->telemetryInfo;
36+
}
37+
38+
public function stdout(): string
39+
{
40+
return $this->stdout;
41+
}
42+
43+
public function stderr(): string
44+
{
45+
return $this->stderr;
46+
}
47+
48+
public function asString(): string
49+
{
50+
return 'Child Process Finished';
51+
}
52+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\Event\TestRunner;
11+
12+
use PHPUnit\Event\Subscriber;
13+
14+
/**
15+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
16+
*/
17+
interface ChildProcessFinishedSubscriber extends Subscriber
18+
{
19+
public function notify(ChildProcessFinished $event): void;
20+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\Event\TestRunner;
11+
12+
use PHPUnit\Event\Event;
13+
use PHPUnit\Event\Telemetry;
14+
15+
/**
16+
* @immutable
17+
*
18+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
19+
*/
20+
final readonly class ChildProcessStarted implements Event
21+
{
22+
private Telemetry\Info $telemetryInfo;
23+
24+
public function __construct(Telemetry\Info $telemetryInfo)
25+
{
26+
$this->telemetryInfo = $telemetryInfo;
27+
}
28+
29+
public function telemetryInfo(): Telemetry\Info
30+
{
31+
return $this->telemetryInfo;
32+
}
33+
34+
public function asString(): string
35+
{
36+
return 'Child Process Started';
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\Event\TestRunner;
11+
12+
use PHPUnit\Event\Subscriber;
13+
14+
/**
15+
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
16+
*/
17+
interface ChildProcessStartedSubscriber extends Subscriber
18+
{
19+
public function notify(ChildProcessStarted $event): void;
20+
}

src/Event/Facade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ private function registerDefaultTypes(TypeMap $typeMap): void
229229
TestRunner\GarbageCollectionDisabled::class,
230230
TestRunner\GarbageCollectionTriggered::class,
231231
TestRunner\GarbageCollectionEnabled::class,
232+
TestRunner\ChildProcessFinished::class,
233+
TestRunner\ChildProcessStarted::class,
232234

233235
TestSuite\Filtered::class,
234236
TestSuite\Finished::class,

src/Framework/TestRunner/templates/class.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ function __phpunit_run_isolated_test()
7878
}
7979
}
8080

81+
Facade::emitter()->testRunnerFinishedChildProcess($output, '');
82+
8183
file_put_contents(
8284
'{processResultFile}',
8385
serialize(

src/Framework/TestRunner/templates/method.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ function __phpunit_run_isolated_test()
7878
}
7979
}
8080

81+
Facade::emitter()->testRunnerFinishedChildProcess($output, '');
82+
8183
file_put_contents(
8284
'{processResultFile}',
8385
serialize(

src/Runner/PHPT/PhptTestCase.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use function var_export;
4444
use PHPUnit\Event\Code\Phpt;
4545
use PHPUnit\Event\Code\ThrowableBuilder;
46+
use PHPUnit\Event\Facade;
4647
use PHPUnit\Event\Facade as EventFacade;
4748
use PHPUnit\Event\NoPreviousThrowableException;
4849
use PHPUnit\Framework\Assert;
@@ -196,6 +197,8 @@ public function run(): void
196197
),
197198
);
198199

200+
Facade::emitter()->testRunnerFinishedChildProcess($jobResult->stdout(), $jobResult->stderr());
201+
199202
$this->output = $jobResult->stdout();
200203

201204
if (CodeCoverage::instance()->isActive()) {
@@ -430,6 +433,8 @@ private function shouldTestBeSkipped(array $sections, array $settings): bool
430433
),
431434
);
432435

436+
Facade::emitter()->testRunnerFinishedChildProcess($jobResult->stdout(), $jobResult->stderr());
437+
433438
if (!strncasecmp('skip', ltrim($jobResult->stdout()), 4)) {
434439
$message = '';
435440

@@ -459,12 +464,14 @@ private function runClean(array $sections, bool $collectCoverage): void
459464
return;
460465
}
461466

462-
JobRunnerRegistry::run(
467+
$result = JobRunnerRegistry::run(
463468
new Job(
464469
$this->render($sections['CLEAN']),
465470
$this->settings($collectCoverage),
466471
),
467472
);
473+
474+
Facade::emitter()->testRunnerFinishedChildProcess($result->stdout(), $result->stderr());
468475
}
469476

470477
/**

0 commit comments

Comments
 (0)