mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
patchutils.py: Add tests for multiple patches in a single file.
This commit is contained in:
parent
a3bc186a20
commit
3ad772bb1f
@ -814,6 +814,55 @@ if __name__ == "__main__":
|
||||
self.assertEqual(patches[0].is_binary, False)
|
||||
self.assertEqual(patches[0].modified_file, "test.txt")
|
||||
|
||||
def test_multi(self):
|
||||
with open("tests/multi.patch") as fp:
|
||||
source = fp.read().split("\n")
|
||||
|
||||
patchfile = tempfile.NamedTemporaryFile(mode='w+')
|
||||
patchfile.write("\n".join(source))
|
||||
patchfile.flush()
|
||||
|
||||
patches = list(read_patch(patchfile.name))
|
||||
self.assertEqual(len(patches), 3)
|
||||
|
||||
self.assertEqual(patches[0].patch_author, "Author Name")
|
||||
self.assertEqual(patches[0].patch_email, "author@email.com")
|
||||
self.assertEqual(patches[0].patch_subject, "component: Replace arg1 with arg2.")
|
||||
self.assertEqual(patches[0].patch_revision, 3)
|
||||
self.assertEqual(patches[0].signed_off_by, [("Author Name", "author@email.com"),
|
||||
("Other Developer", "other@email.com")])
|
||||
self.assertEqual(patches[0].filename, patchfile.name)
|
||||
self.assertEqual(patches[0].is_binary, False)
|
||||
self.assertEqual(patches[0].modified_file, "other_test.txt")
|
||||
|
||||
lines = patches[0].read().rstrip("\n").split("\n")
|
||||
self.assertEqual(lines, source[11:24])
|
||||
|
||||
self.assertEqual(patches[1].patch_author, "Author Name")
|
||||
self.assertEqual(patches[1].patch_email, "author@email.com")
|
||||
self.assertEqual(patches[1].patch_subject, "component: Replace arg1 with arg2.")
|
||||
self.assertEqual(patches[1].patch_revision, 3)
|
||||
self.assertEqual(patches[1].signed_off_by, [("Author Name", "author@email.com"),
|
||||
("Other Developer", "other@email.com")])
|
||||
self.assertEqual(patches[1].filename, patchfile.name)
|
||||
self.assertEqual(patches[1].is_binary, False)
|
||||
self.assertEqual(patches[1].modified_file, "test.txt")
|
||||
|
||||
lines = patches[1].read().rstrip("\n").split("\n")
|
||||
self.assertEqual(lines, source[24:46])
|
||||
|
||||
self.assertEqual(patches[2].patch_author, "Other Developer")
|
||||
self.assertEqual(patches[2].patch_email, "other@email.com")
|
||||
self.assertEqual(patches[2].patch_subject, "component: Replace arg2 with arg3.")
|
||||
self.assertEqual(patches[2].patch_revision, 4)
|
||||
self.assertEqual(patches[2].signed_off_by, [("Other Developer", "other@email.com")])
|
||||
self.assertEqual(patches[2].filename, patchfile.name)
|
||||
self.assertEqual(patches[2].is_binary, False)
|
||||
self.assertEqual(patches[2].modified_file, "test.txt")
|
||||
|
||||
lines = patches[2].read().rstrip("\n").split("\n")
|
||||
self.assertEqual(lines, source[58:71])
|
||||
|
||||
# Basic tests for apply_patch()
|
||||
class PatchApplyTests(unittest.TestCase):
|
||||
def test_apply(self):
|
||||
|
73
staging/tests/multi.patch
Normal file
73
staging/tests/multi.patch
Normal file
@ -0,0 +1,73 @@
|
||||
From be07df750862699f2515c0ac0ceb7a6c25e9458a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Author=20Name?= <author@email.com>
|
||||
Subject: [PATCH v3] component: Replace arg1 with arg2.
|
||||
|
||||
Signed-off-by: =?UTF-8?q?Author=20Name?= <author@email.com>
|
||||
Signed-off-by: Other Developer <other@email.com>
|
||||
---
|
||||
other_test.txt | 2 +-
|
||||
test.txt | 4 ++--
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/other_test.txt b/other_test.txt
|
||||
index a26e3f5..187ea7d 100644
|
||||
--- a/other_test.txt
|
||||
+++ b/other_test.txt
|
||||
@@ -1,7 +1,7 @@
|
||||
other_line1();
|
||||
other_line2();
|
||||
other_line3();
|
||||
-function(arg1);
|
||||
+function(arg2);
|
||||
other_line4();
|
||||
other_line5();
|
||||
other_line6();
|
||||
diff --git a/test.txt b/test.txt
|
||||
index c9947e7..5d7eff8 100644
|
||||
--- a/test.txt
|
||||
+++ b/test.txt
|
||||
@@ -1,7 +1,7 @@
|
||||
line1();
|
||||
line2();
|
||||
line3();
|
||||
-function(arg1);
|
||||
+function(arg2);
|
||||
line5();
|
||||
line6();
|
||||
line7();
|
||||
@@ -9,7 +9,7 @@ line8();
|
||||
line9();
|
||||
line10();
|
||||
line11();
|
||||
-function(arg1);
|
||||
+function(arg2);
|
||||
line12();
|
||||
line13();
|
||||
line14();
|
||||
--
|
||||
2.7.1
|
||||
|
||||
From 801d4e778daf4f66dbe373e0a62cf0eb2fc0a7a3 Mon Sep 17 00:00:00 2001
|
||||
From: Other Developer <other@email.com>
|
||||
Subject: component: Replace arg2 with arg3. (v4)
|
||||
|
||||
Signed-off-by: Other Developer <other@email.com>
|
||||
---
|
||||
test.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test.txt b/test.txt
|
||||
index 5d7eff8..73811d5 100644
|
||||
--- a/test.txt
|
||||
+++ b/test.txt
|
||||
@@ -1,7 +1,7 @@
|
||||
line1();
|
||||
line2();
|
||||
line3();
|
||||
-function(arg2);
|
||||
+function(arg3);
|
||||
line5();
|
||||
line6();
|
||||
line7();
|
||||
--
|
||||
2.7.1
|
Loading…
Reference in New Issue
Block a user