ExecTrait.php in Drupal 9
File
core/tests/Drupal/Tests/Composer/Plugin/Scaffold/ExecTrait.php
View source
<?php
namespace Drupal\Tests\Composer\Plugin\Scaffold;
use Symfony\Component\Process\Process;
trait ExecTrait {
protected function mustExec($cmd, $cwd, array $env = []) {
$process = Process::fromShellCommandline($cmd, $cwd, $env + [
'PATH' => getenv('PATH'),
'HOME' => getenv('HOME'),
]);
$process
->setTimeout(300)
->setIdleTimeout(300)
->run();
$exitCode = $process
->getExitCode();
if (0 != $exitCode) {
throw new \RuntimeException("Exit code: {$exitCode}\n\n" . $process
->getErrorOutput() . "\n\n" . $process
->getOutput());
}
return $process
->getOutput();
}
}
Traits
Name |
Description |
ExecTrait |
Convenience class for creating fixtures. |