public function testExceptionIsThrownWhenGettingRunnerIfNoFactorySupportsExercise() { $exercise = new CliExerciseImpl(); $manager = new RunnerManager(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Exercise Type: "CLI" not supported'); $manager->getRunner($exercise); }
/** * Run a student's solution against a specific exercise. Does not invoke checks. Invokes the * correct runner for the exercise based on the exercise type. Various events are triggered throughout the process. * The output of the solution is written directly to the `OutputInterface` instance. * * @param ExerciseInterface $exercise The exercise instance. * @param Input $input The command line arguments passed to the command. * @param OutputInterface $output An output instance capable of writing to stdout. * @return bool Whether the solution ran successfully or not. */ public function run(ExerciseInterface $exercise, Input $input, OutputInterface $output) { $exercise->configure($this); $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('run.start', $exercise, $input)); try { $exitStatus = $this->runnerManager->getRunner($exercise)->run($input, $output); } finally { $this->eventDispatcher->dispatch(new ExerciseRunnerEvent('run.finish', $exercise, $input)); } return $exitStatus; }