Revert patches in reverse order
Change-Id: I8f3431691d93043fb49570f68417cf3011b5d806
This commit is contained in:
parent
fdafa2666d
commit
60386fe00c
@ -168,7 +168,7 @@ def test_applied_patches(mocker, container, prefix, patches, error):
|
||||
pass
|
||||
assert [
|
||||
mock.call(container, prefix, *patches),
|
||||
mock.call(container, prefix, *patches, revert=True)
|
||||
mock.call(container, prefix, *patches[::-1], revert=True)
|
||||
] == apply_patches.call_args_list
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@ def test_applied_context_manager(mocker, patches, cwd, is_exception):
|
||||
pass
|
||||
assert [
|
||||
mock.call(cwd, patches),
|
||||
mock.call(cwd, patches, revert=True)
|
||||
mock.call(cwd, patches[::-1], revert=True)
|
||||
] == patch_mock.call_args_list
|
||||
|
||||
|
||||
|
@ -42,7 +42,11 @@ def test_applied_patches(mocker, node, mock_open,
|
||||
error_idx = error_idx or len(patches) + 1
|
||||
mock_shutil_side_effect = []
|
||||
|
||||
revert_patches = []
|
||||
|
||||
for idx, path in enumerate(patches):
|
||||
if idx < error_idx:
|
||||
revert_patches.append(path)
|
||||
if idx <= error_idx:
|
||||
mock_open_calls.append(mock.call(path, "rb"))
|
||||
mock_patch_calls.append(mock.call(
|
||||
@ -57,8 +61,8 @@ def test_applied_patches(mocker, node, mock_open,
|
||||
else:
|
||||
mock_shutil_side_effect.append(None)
|
||||
|
||||
for idx, path in enumerate(patches):
|
||||
if idx < error_idx:
|
||||
revert_patches.reverse()
|
||||
for path in revert_patches:
|
||||
mock_shutil_side_effect.append(None)
|
||||
mock_patch_calls.append(mock.call(
|
||||
["patch", "-R", "-p1", "-d", cwd], node=node, stdin=ssh.PIPE
|
||||
|
@ -239,7 +239,7 @@ def applied_patches(container, prefix, *patches):
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
apply_patches(container, prefix, *patches, revert=True)
|
||||
apply_patches(container, prefix, *patches[::-1], revert=True)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
|
@ -36,7 +36,7 @@ def applied_patch(cwd, *patches):
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
patch_apply(cwd, patches, revert=True)
|
||||
patch_apply(cwd, patches[::-1], revert=True)
|
||||
|
||||
|
||||
def get_filenames_from_single_patch(patch):
|
||||
|
@ -245,6 +245,7 @@ def applied_patches(cwd, node, *patches):
|
||||
patched_files.append(path)
|
||||
yield
|
||||
finally:
|
||||
patched_files.reverse()
|
||||
for path in patched_files:
|
||||
with open(path, "rb") as patch:
|
||||
with popen(
|
||||
|
Loading…
Reference in New Issue
Block a user