Skip to content
Snippets Groups Projects
Commit acef843f authored by Josh Rosen's avatar Josh Rosen Committed by Andrew Or
Browse files

[SPARK-15975] Fix improper Popen retcode code handling in dev/run-tests

In the `dev/run-tests.py` script we check a `Popen.retcode` for success using `retcode > 0`, but this is subtlety wrong because Popen's return code will be negative if the child process was terminated by a signal: https://docs.python.org/2/library/subprocess.html#subprocess.Popen.returncode

In order to properly handle signals, we should change this to check `retcode != 0` instead.

Author: Josh Rosen <joshrosen@databricks.com>

Closes #13692 from JoshRosen/dev-run-tests-return-code-handling.
parent bbad4cb4
No related branches found
No related tags found
No related merge requests found
...@@ -294,7 +294,7 @@ def exec_sbt(sbt_args=()): ...@@ -294,7 +294,7 @@ def exec_sbt(sbt_args=()):
print(line, end='') print(line, end='')
retcode = sbt_proc.wait() retcode = sbt_proc.wait()
if retcode > 0: if retcode != 0:
exit_from_command_with_retcode(sbt_cmd, retcode) exit_from_command_with_retcode(sbt_cmd, retcode)
......
...@@ -53,7 +53,10 @@ else: ...@@ -53,7 +53,10 @@ else:
def exit_from_command_with_retcode(cmd, retcode): def exit_from_command_with_retcode(cmd, retcode):
print("[error] running", ' '.join(cmd), "; received return code", retcode) if retcode < 0:
print("[error] running", ' '.join(cmd), "; process was terminated by signal", -retcode)
else:
print("[error] running", ' '.join(cmd), "; received return code", retcode)
sys.exit(int(os.environ.get("CURRENT_BLOCK", 255))) sys.exit(int(os.environ.get("CURRENT_BLOCK", 255)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment