Abort if a script fails to execute, and exit with the exit code of the process, fixes #1943
parent
7449162aa4
commit
5d360ab43b
|
@ -120,8 +120,10 @@ class EventDispatcher
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (0 !== $this->process->execute($callable)) {
|
if (0 !== ($exitCode = $this->process->execute($callable))) {
|
||||||
$event->getIO()->write(sprintf('<error>Script %s handling the %s event returned with an error: %s</error>', $callable, $event->getName(), $this->process->getErrorOutput()));
|
$event->getIO()->write(sprintf('<error>Script %s handling the %s event returned with an error</error>', $callable, $event->getName()));
|
||||||
|
|
||||||
|
throw new \RuntimeException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,8 @@ class EventDispatcherTest extends TestCase
|
||||||
|
|
||||||
$process->expects($this->once())
|
$process->expects($this->once())
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($command);
|
->with($command)
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
|
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,8 @@ class EventDispatcherTest extends TestCase
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$process->expects($this->exactly(2))
|
$process->expects($this->exactly(2))
|
||||||
->method('execute');
|
->method('execute')
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$listeners = array(
|
$listeners = array(
|
||||||
'echo -n foo',
|
'echo -n foo',
|
||||||
|
@ -165,8 +167,9 @@ class EventDispatcherTest extends TestCase
|
||||||
|
|
||||||
$io->expects($this->once())
|
$io->expects($this->once())
|
||||||
->method('write')
|
->method('write')
|
||||||
->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with an error: </error>'));
|
->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with an error</error>'));
|
||||||
|
|
||||||
|
$this->setExpectedException('RuntimeException');
|
||||||
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
|
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue