-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parser: Fix parsing of patches with a trailing no-newline marker
If a patch ends with a "No newline at end of file" marker, it is incorrectly considered part of the comment. Add a testcase which shows the bug, and then fix the parser. The parser fix is hopefully sufficiently specific so as to not break any other unrelated case. But .. Signed-off-by: Michael Ellerman <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
apps/patchwork/tests/mail/0011-no-newline-at-end-of-file.mbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Subject: [PATCH v3 5/5] selftests, powerpc: Add test for VPHN | ||
From: Greg Kurz <[email protected]> | ||
To: Michael Ellerman <[email protected]> | ||
Cc: Benjamin Herrenschmidt <[email protected]>, | ||
[email protected] | ||
Date: Mon, 23 Feb 2015 16:14:44 +0100 | ||
MIME-Version: 1.0 | ||
Content-Type: text/plain; charset="utf-8" | ||
Content-Transfer-Encoding: 8bit | ||
|
||
The goal is to verify vphn_unpack_associativity() parses VPHN numbers | ||
correctly. We feed it with a variety of input values and compare with | ||
expected results. | ||
|
||
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile | ||
index 1d5e7ad..476b8dd 100644 | ||
--- a/tools/testing/selftests/powerpc/Makefile | ||
+++ b/tools/testing/selftests/powerpc/Makefile | ||
@@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR | ||
|
||
export CC CFLAGS | ||
|
||
-TARGETS = pmu copyloops mm tm primitives stringloops | ||
+TARGETS = pmu copyloops mm tm primitives stringloops vphn | ||
|
||
endif | ||
|
||
diff --git a/tools/testing/selftests/powerpc/vphn/vphn.c b/tools/testing/selftests/powerpc/vphn/vphn.c | ||
new file mode 120000 | ||
index 0000000..186b906 | ||
--- /dev/null | ||
+++ b/tools/testing/selftests/powerpc/vphn/vphn.c | ||
@@ -0,0 +1 @@ | ||
+../../../../../arch/powerpc/mm/vphn.c | ||
\ No newline at end of file | ||
diff --git a/tools/testing/selftests/powerpc/vphn/vphn.h b/tools/testing/selftests/powerpc/vphn/vphn.h | ||
new file mode 120000 | ||
index 0000000..7131efe | ||
--- /dev/null | ||
+++ b/tools/testing/selftests/powerpc/vphn/vphn.h | ||
@@ -0,0 +1 @@ | ||
+../../../../../arch/powerpc/mm/vphn.h | ||
\ No newline at end of file | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,6 +433,21 @@ def testPatch(self): | |
self.assertTrue(patch is not None) | ||
self.assertTrue(comment is not None) | ||
|
||
class NoNewlineAtEndOfFilePatchTest(MBoxPatchTest): | ||
mail_file = '0011-no-newline-at-end-of-file.mbox' | ||
|
||
def testPatch(self): | ||
(patch, comment) = find_content(self.project, self.mail) | ||
self.assertTrue(patch is not None) | ||
self.assertTrue(comment is not None) | ||
self.assertTrue(patch.content.startswith('diff --git a/tools/testing/selftests/powerpc/Makefile')) | ||
# Confirm the trailing no newline marker doesn't end up in the comment | ||
self.assertFalse(comment.content.rstrip().endswith('\ No newline at end of file')) | ||
# Confirm it's instead at the bottom of the patch | ||
self.assertTrue(patch.content.rstrip().endswith('\ No newline at end of file')) | ||
# Confirm we got both markers | ||
self.assertEqual(2, patch.content.count('\ No newline at end of file')) | ||
|
||
class DelegateRequestTest(TestCase): | ||
patch_filename = '0001-add-line.patch' | ||
msgid = '<[email protected]>' | ||
|