Skip to content

TaskExitException should contain the error output #1153

@prudloff-insite

Description

@prudloff-insite

This is a followup to findings in #919.

Steps to reproduce

We have a task like this:

  public function test() {
    $sshTask = $this->taskExecStack();
    $sshTask
      ->interactive(FALSE)
      ->exec('echo "this command output is very long"')
      ->exec('echo "this command output is very long"')
      ->exec('echo "this command output is very long"')
      ->exec('echo "this command output is very long"')
      ->exec('echo "this command output is very long"')
      ->exec('echo "this command output is very long"')
      ->exec('invalid_cmd')
      ->run();
  }

Expected behavior

If the exception contained the error output, it would be quite readable (with the error easily spotted at the end):

 [ExecStack] echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && invalid_cmd
 [ExecStack] Running echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 invalid_cmd
this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
sh: 1: invalid_cmd: not found
 [ExecStack]  Exit code 127  Time 0.003s
 [notice] Stopping on fail. Exiting....
 [error]  Exit Code: 127 
 [error]    in task Robo\Task\Base\ExecStack 

  sh: 1: invalid_cmd: not found
 

Actual behavior

It displays this:

 [ExecStack] echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && echo "this command output is very long" && invalid_cmd
 [ExecStack] Running echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 echo "this command output is very long" &&
 invalid_cmd
this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
sh: 1: invalid_cmd: not found
 [ExecStack]  Exit code 127  Time 0.003s
 [notice] Stopping on fail. Exiting....
 [error]  Exit Code: 127 
 [error]    in task Robo\Task\Base\ExecStack 

  this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
this command output is very long
 

This confuses our users because the error is buried between the long output printed twice so it is hard to find.

System Configuration

PHP 8.1.27 on Linux Mint 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions