SonarQube
  1. SonarQube
  2. SONAR-2969

Improve CommandExecutor to execute and test the exit code

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.12
    • Fix Version/s: None
    • Component/s: API
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Currently, CommandExecutor.execute() returns the exit code of the executed command.

      However, there are many cases in which we expect an internal tool to exit with a given (and possibly set of) exit codes.

      CommandExecutor should provide a way, out of the box, to both execute and test the exit code, instead of leaving that logic to its callers.

      One option is to add a method such as:

      executeAndExpect(command, int acceptableCodes...)
      

      Anoter option is to use a property of a Command, but this might prevent the use case of several executions of the same Command expecting different exit codes across multiple executions.

      In order to make it possible to more easily reuse the CommandException class, it should provide a constructor which does not take an inner exception as argument. The current workaround is to pass null as the inner exception argument.

        Issue Links

          Activity

          Hide
          Evgeny Mandrikov added a comment -

          I'm not sure that CommandExecutor should be responsible to perform such check. Maybe would be better to provide helper method or class.

          Show
          Evgeny Mandrikov added a comment - I'm not sure that CommandExecutor should be responsible to perform such check. Maybe would be better to provide helper method or class.
          Hide
          Dinesh Bolkensteyn added a comment -

          A helper class with a single method is useless.

          But a helper method why not, after all that is what this jira ticket is all about.

          Show
          Dinesh Bolkensteyn added a comment - A helper class with a single method is useless. But a helper method why not, after all that is what this jira ticket is all about.

            People

            • Assignee:
              Unassigned
              Reporter:
              Dinesh Bolkensteyn
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: