builder/utils/execute_cmd: remove useless return value and add a test

Since we never pass in subprocess.PIPE for stdin/stdout/stderr,
subprocess.communicate() does nothing, and the return out/err tuple
was always empty.
This commit is contained in:
Owen W. Taylor
2021-01-27 16:21:24 -05:00
parent 728b96133d
commit cff90e587a
2 changed files with 17 additions and 2 deletions

View File

@@ -17,6 +17,22 @@ from module_build_service.scheduler.db_session import db_session
from tests import read_staged_data, scheduler_init_data
def test_execute_cmd(tmpdir, caplog):
logfile = str(tmpdir / "out.log")
with open(logfile, "w") as f:
utils.execute_cmd(["echo", "hello"], output=f)
with open(logfile) as f:
assert f.read() == "hello\n"
assert 'Executing the command "echo hello", output log: %s' % logfile in caplog.text
def test_execute_cmd_fail():
with pytest.raises(RuntimeError):
utils.execute_cmd(["false"])
@pytest.mark.parametrize("variation", ("none", "empty", "already_downloaded"))
@patch("requests.get")
@patch("koji.ClientSession")