Skip to content

Commit

Permalink
Change run_subprocess to return CompletedProcess object
Browse files Browse the repository at this point in the history
As requested in #1595
  • Loading branch information
favilo committed Jan 30, 2024
1 parent 6611f67 commit f842646
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion esrally/mechanic/supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def run(self, command, override_src_dir=None):
console.info("Creating installable binary from source files")
self.logger.info("Running build command [%s]", build_cmd)

if process.run_subprocess(build_cmd):
if process.run_subprocess(build_cmd).returncode != 0:
msg = f"Executing '{command}' failed. The last 20 lines in the build log file are:\n"
msg += "=========================================================================================================\n"
with open(log_file, encoding="utf-8") as f:
Expand Down
2 changes: 1 addition & 1 deletion esrally/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def run_subprocess(command_line):
return subprocess.call(command_line, shell=True)
return subprocess.run(command_line, shell=True, capture_output=True, check=False)


def run_subprocess_with_output(command_line, env=None):
Expand Down
4 changes: 2 additions & 2 deletions tests/mechanic/supplier_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class TestBuilder:
@mock.patch("esrally.utils.jvm.resolve_path")
def test_build_on_jdk_8(self, jvm_resolve_path, mock_run_subprocess):
jvm_resolve_path.return_value = (8, "/opt/jdk8")
mock_run_subprocess.return_value = False
mock_run_subprocess.return_value = mock.Mock(returncode=0)

b = supplier.Builder(src_dir="/src", build_jdk=8, log_dir="logs")
b.build(["./gradlew clean", "./gradlew assemble"])
Expand All @@ -200,7 +200,7 @@ def test_build_on_jdk_8(self, jvm_resolve_path, mock_run_subprocess):
@mock.patch("esrally.utils.jvm.resolve_path")
def test_build_on_jdk_10(self, jvm_resolve_path, mock_run_subprocess):
jvm_resolve_path.return_value = (10, "/opt/jdk10")
mock_run_subprocess.return_value = False
mock_run_subprocess.return_value = mock.Mock(returncode=0)

b = supplier.Builder(src_dir="/src", build_jdk=8, log_dir="logs")
b.build(["./gradlew clean", "./gradlew assemble"])
Expand Down

0 comments on commit f842646

Please sign in to comment.