Update from upstream #11
@ -291,16 +291,21 @@ class KojiWrapper(object):
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
||||
first_line = output.splitlines()[0]
|
||||
match = re.search(r"^(\d+)$", first_line)
|
||||
if not match:
|
||||
# Look for first line that contains only a number. This is the ID of
|
||||
# the new task. Usually this should be the first line, but there may be
|
||||
# warnings before it.
|
||||
for line in output.splitlines():
|
||||
match = re.search(r"^(\d+)$", line)
|
||||
if match:
|
||||
task_id = int(match.groups()[0])
|
||||
break
|
||||
|
||||
if not task_id:
|
||||
raise RuntimeError(
|
||||
"Could not find task ID in output. Command '%s' returned '%s'."
|
||||
% (" ".join(command), output)
|
||||
)
|
||||
|
||||
task_id = int(match.groups()[0])
|
||||
|
||||
self.save_task_id(task_id)
|
||||
|
||||
retcode, output = self._wait_for_task(task_id, logfile=log_file)
|
||||
|
@ -668,6 +668,30 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
@mock.patch("pungi.wrappers.kojiwrapper.run")
|
||||
def test_run_runroot_cmd_with_warnings_before_task_id(self, run):
|
||||
cmd = ["koji", "runroot", "--task-id"]
|
||||
run.return_value = (0, "DeprecatioNWarning: whatever\n1234\n")
|
||||
output = "Output ..."
|
||||
self.koji._wait_for_task = mock.Mock(return_value=(0, output))
|
||||
|
||||
result = self.koji.run_runroot_cmd(cmd)
|
||||
self.assertDictEqual(result, {"retcode": 0, "output": output, "task_id": 1234})
|
||||
self.assertEqual(
|
||||
run.call_args_list,
|
||||
[
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env={"FOO": "BAR", "PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
@mock.patch("shutil.rmtree")
|
||||
@mock.patch("tempfile.mkdtemp")
|
||||
@mock.patch("pungi.wrappers.kojiwrapper.run")
|
||||
|
Loading…
Reference in New Issue
Block a user