diff --git a/src/Symfony/Component/Process/Exception/ProcessFailedException.php b/src/Symfony/Component/Process/Exception/ProcessFailedException.php index 7523a5e9cd4e..328acfde5e88 100644 --- a/src/Symfony/Component/Process/Exception/ProcessFailedException.php +++ b/src/Symfony/Component/Process/Exception/ProcessFailedException.php @@ -28,10 +28,11 @@ public function __construct(Process $process) throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); } - $error = sprintf('The command "%s" failed.'."\nExit Code: %s(%s)", + $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s", $process->getCommandLine(), $process->getExitCode(), - $process->getExitCodeText() + $process->getExitCodeText(), + $process->getWorkingDirectory() ); if (!$process->isOutputDisabled()) { diff --git a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php index de37353f9175..0d763a470d19 100644 --- a/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessFailedExceptionTest.php @@ -51,10 +51,11 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( $exitText = 'General error'; $output = 'Command output'; $errorOutput = 'FATAL: Unexpected error'; + $workingDirectory = getcwd(); $process = $this->getMock( 'Symfony\Component\Process\Process', - array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled'), + array('isSuccessful', 'getOutput', 'getErrorOutput', 'getExitCode', 'getExitCodeText', 'isOutputDisabled', 'getWorkingDirectory'), array($cmd) ); $process->expects($this->once()) @@ -81,10 +82,14 @@ public function testProcessFailedExceptionPopulatesInformationFromProcessOutput( ->method('isOutputDisabled') ->will($this->returnValue(false)); + $process->expects($this->once()) + ->method('getWorkingDirectory') + ->will($this->returnValue($workingDirectory)); + $exception = new ProcessFailedException($process); $this->assertEquals( - "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}", + "The command \"$cmd\" failed.\n\nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory}\n\nOutput:\n================\n{$output}\n\nError Output:\n================\n{$errorOutput}", $exception->getMessage() ); } @@ -98,10 +103,11 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() $cmd = 'php'; $exitCode = 1; $exitText = 'General error'; + $workingDirectory = getcwd(); $process = $this->getMock( 'Symfony\Component\Process\Process', - array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput'), + array('isSuccessful', 'isOutputDisabled', 'getExitCode', 'getExitCodeText', 'getOutput', 'getErrorOutput', 'getWorkingDirectory'), array($cmd) ); $process->expects($this->once()) @@ -126,10 +132,14 @@ public function testDisabledOutputInFailedExceptionDoesNotPopulateOutput() ->method('isOutputDisabled') ->will($this->returnValue(true)); + $process->expects($this->once()) + ->method('getWorkingDirectory') + ->will($this->returnValue($workingDirectory)); + $exception = new ProcessFailedException($process); $this->assertEquals( - "The command \"$cmd\" failed.\nExit Code: $exitCode($exitText)", + "The command \"$cmd\" failed.\n\nExit Code: $exitCode($exitText)\n\nWorking directory: {$workingDirectory}", $exception->getMessage() ); }