/**
* Execute behat command for featurename and return exit status.
*
* @param string $featurename name of the feature
* @param string $featurepath path of feature file
* @return int status code.
*/
protected function execute_behat_generator($featurename, $featurepath)
{
$cmd = "vendor/bin/behat --config " . util::get_tool_dir() . DIRECTORY_SEPARATOR . 'behat.yml ' . $featurepath;
$process = new symfonyprocess($cmd);
$process->setWorkingDirectory(__DIR__ . "/../../moodle");
$process->setTimeout(null);
$process->start();
if ($process->getStatus() !== 'started') {
echo "Error starting process: {$featurename}";
$process->signal(SIGKILL);
exit(1);
}
while ($process->isRunning()) {
$output = $process->getIncrementalOutput();
// Don't show start data everytime.
$output = preg_replace('/[a-z0-9.\\(\\)].*/im', '', $output);
$op = trim($output);
if (!empty($op)) {
echo $output;
}
}
return $process->getExitCode();
}