Skip to content

Commit

Permalink
GH-1433 Allow errors to be returned from runCmdReturnStr
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jul 25, 2023
1 parent 00b045c commit 9e35162
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/TestHarness/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def checkDelayedOutput(popen, cmd, ignoreError=False):
Utils.checkOutputFileWrite(start, cmd, output, error)
if popen.returncode != 0 and not ignoreError:
raise subprocess.CalledProcessError(returncode=popen.returncode, cmd=cmd, output=output, stderr=error)
return output.decode("utf-8")
return output.decode("utf-8") if popen.returncode == 0 else error.decode("utf-8")

@staticmethod
def errorExit(msg="", raw=False, errorCode=1):
Expand Down Expand Up @@ -304,13 +304,13 @@ def runCmdArrReturnJson(cmdArr, trace=False, silentErrors=True):
return Utils.toJson(retStr)

@staticmethod
def runCmdReturnStr(cmd, trace=False):
def runCmdReturnStr(cmd, trace=False, ignoreError=False):
cmdArr=shlex.split(cmd)
return Utils.runCmdArrReturnStr(cmdArr)
return Utils.runCmdArrReturnStr(cmdArr, ignoreError=ignoreError)

@staticmethod
def runCmdArrReturnStr(cmdArr, trace=False):
retStr=Utils.checkOutput(cmdArr)
def runCmdArrReturnStr(cmdArr, trace=False, ignoreError=False):
retStr=Utils.checkOutput(cmdArr, ignoreError=ignoreError)
if trace: Utils.Print ("RAW > %s" % (retStr))
return retStr

Expand Down

0 comments on commit 9e35162

Please sign in to comment.