Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1595: Add method to process.py to return both return code and logs #1828

Merged
merged 7 commits into from
Feb 15, 2024
Merged
Next Next commit
Change run_subprocess to return CompletedProcess object
As requested in #1595
  • Loading branch information
favilo committed Jan 31, 2024
commit f9a8a299b2f9b6611bef8cbb41dfc05ed4a95a25
2 changes: 1 addition & 1 deletion esrally/mechanic/supplier.py
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion esrally/utils/process.py
Original file line number Diff line number Diff line change
@@ -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)
favilo marked this conversation as resolved.
Show resolved Hide resolved


def run_subprocess_with_output(command_line, env=None):
4 changes: 2 additions & 2 deletions tests/mechanic/supplier_test.py
Original file line number Diff line number Diff line change
@@ -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"])
@@ -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"])
Loading