Skip to content

Commit f2fddf5

Browse files
committed
Failing test for running subjects with different executors
1 parent 7693daf commit f2fddf5

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

lib/Benchmark/Runner.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ private function runVariant(
300300
$this->logger->variantEnd($variant);
301301

302302
if ($config->getStopOnError()) {
303-
dump($e->getMessage());
304303
throw new StopOnErrorException();
305304
}
306305

tests/Unit/Benchmark/RunnerTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,36 @@ public function testCallBeforeAndAfterClassWithBenchmarkExecutorWhenCustomSubjec
376376
self::assertTrue($this->executor->hasMethodBeenExecuted('afterClass'), 'after');
377377
}
378378

379+
public function testRunSubjectsWithDifferentExecutors(): void
380+
{
381+
TestUtil::configureBenchmarkMetadata($this->benchmark, []);
382+
383+
$subject1 = new SubjectMetadata($this->benchmark->reveal(), 'name');
384+
$subject1->setExecutor(new ExecutorMetadata('executor_1', []));
385+
$subject2 = new SubjectMetadata($this->benchmark->reveal(), 'name');
386+
$subject2->setExecutor(new ExecutorMetadata('executor_2', []));
387+
$this->benchmark->getSubjects()->willReturn([
388+
$subject1,
389+
$subject2,
390+
]);
391+
392+
$executor1 = new TestExecutor();
393+
$executor2 = new TestExecutor();
394+
$this->executorRegistry->getService('executor_1')->willReturn($executor1);
395+
$this->executorRegistry->getService('executor_2')->willReturn($executor2);
396+
$this->executorRegistry->getConfig(['executor'=> 'executor_1'])->willReturn($this->resolveExecutorConfig([
397+
'executor' => 'executor_1'
398+
]));
399+
$this->executorRegistry->getConfig(['executor'=> 'executor_2'])->willReturn($this->resolveExecutorConfig([
400+
'executor' => 'executor_2'
401+
]));
402+
403+
$this->runner->run([ $this->benchmark->reveal() ], RunnerConfig::create());
404+
405+
self::assertEquals(1, $executor1->getExecutedContextCount());
406+
self::assertEquals(1, $executor2->getExecutedContextCount());
407+
}
408+
379409
/**
380410
* It should handle exceptions thrown by the executor.
381411
* It should handle nested exceptions.

0 commit comments

Comments
 (0)