aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/samples/trailers-followup-custody-ref-ordered.txt41
-rw-r--r--tests/samples/trailers-followup-custody-ref-unordered.txt41
-rw-r--r--tests/samples/trailers-followup-custody.mbox65
-rw-r--r--tests/samples/trailers-followup-single-ref-addlink.txt37
-rw-r--r--tests/samples/trailers-followup-single-ref-addmysob.txt36
-rw-r--r--tests/samples/trailers-followup-single-ref-copyccs.txt39
-rw-r--r--tests/samples/trailers-followup-single-ref-defaults.txt35
-rw-r--r--tests/samples/trailers-followup-single-ref-noadd.txt33
-rw-r--r--tests/samples/trailers-followup-single-ref-ordered.txt39
-rw-r--r--tests/samples/trailers-followup-single-ref-sloppy.txt37
-rw-r--r--tests/samples/trailers-followup-single.mbox78
-rw-r--r--tests/samples/trailers-followup-with-cover-ref-covertrailers.txt75
-rw-r--r--tests/samples/trailers-followup-with-cover-ref-defaults.txt73
-rw-r--r--tests/samples/trailers-followup-with-cover.mbox113
-rw-r--r--tests/samples/trailers-test-extinfo.txt29
-rw-r--r--tests/samples/trailers-test-simple.txt24
-rw-r--r--tests/test___init__.py66
17 files changed, 859 insertions, 2 deletions
diff --git a/tests/samples/trailers-followup-custody-ref-ordered.txt b/tests/samples/trailers-followup-custody-ref-ordered.txt
new file mode 100644
index 0000000..383befb
--- /dev/null
+++ b/tests/samples/trailers-followup-custody-ref-ordered.txt
@@ -0,0 +1,41 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Link: https://msgid.link/some@msgid.here
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>
+Cc: Dev Eloper2 <dev-eloper2@example.com>
+Cc: Some List <list-1@lists.example.com>
+Fixes: abcdef01234567890
+Link: https://lore.kernel.org/some@msgid.here # bug discussion
+Suggested-by: Friendly Suggester <suggested-by@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-custody-ref-unordered.txt b/tests/samples/trailers-followup-custody-ref-unordered.txt
new file mode 100644
index 0000000..4b238da
--- /dev/null
+++ b/tests/samples/trailers-followup-custody-ref-unordered.txt
@@ -0,0 +1,41 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Link: https://msgid.link/some@msgid.here
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Suggested-by: Friendly Suggester <suggested-by@example.com>
+Fixes: abcdef01234567890
+Link: https://lore.kernel.org/some@msgid.here # bug discussion
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>
+Cc: Dev Eloper2 <dev-eloper2@example.com>
+Cc: Some List <list-1@lists.example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-custody.mbox b/tests/samples/trailers-followup-custody.mbox
new file mode 100644
index 0000000..0c4e4b8
--- /dev/null
+++ b/tests/samples/trailers-followup-custody.mbox
@@ -0,0 +1,65 @@
+From foo@z Thu Jan 1 00:00:00 1970
+From: Test Test <test@example.com>
+Subject: [PATCH] Simple test
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>,
+ Dev Eloper2 <dev-eloper2@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+
+Follow-up trailer collating test.
+
+Link: https://msgid.link/some@msgid.here
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Suggested-by: Friendly Suggester <suggested-by@example.com>
+Fixes: abcdef01234567890
+Link: https://lore.kernel.org/some@msgid.here # bug discussion
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer1 <followup-reviewer1@example.com>
+Subject: Re: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-1@example.com>
+In-Reply-To: <orig-message@example.com>
+References: <orig-message@example.com>
+
+> This is a simple trailer parsing test.
+
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+
+--
+My sig
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer2 <followup-reviewer2@example.com>
+Subject: Re: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-2@example.com>
+In-Reply-To: <fwup-message-1@example.com>
+References: <orig-message@example.com> <fwup-message-1@example.com>
+
+>> This is a simple trailer parsing test.
+>
+> Reviewed-by: Followup Reviewer1 <reviewer1@example.com>
+
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+
+--
+My sig
diff --git a/tests/samples/trailers-followup-single-ref-addlink.txt b/tests/samples/trailers-followup-single-ref-addlink.txt
new file mode 100644
index 0000000..024c842
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-addlink.txt
@@ -0,0 +1,37 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Link: https://lore.kernel.org/r/orig-message@example.com
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-addmysob.txt b/tests/samples/trailers-followup-single-ref-addmysob.txt
new file mode 100644
index 0000000..9da6c0b
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-addmysob.txt
@@ -0,0 +1,36 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-copyccs.txt b/tests/samples/trailers-followup-single-ref-copyccs.txt
new file mode 100644
index 0000000..3623462
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-copyccs.txt
@@ -0,0 +1,39 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>
+Cc: Dev Eloper2 <dev-eloper2@example.com>
+Cc: Some List <list-1@lists.example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-defaults.txt b/tests/samples/trailers-followup-single-ref-defaults.txt
new file mode 100644
index 0000000..3750c06
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-defaults.txt
@@ -0,0 +1,35 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-noadd.txt b/tests/samples/trailers-followup-single-ref-noadd.txt
new file mode 100644
index 0000000..80a1011
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-noadd.txt
@@ -0,0 +1,33 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-ordered.txt b/tests/samples/trailers-followup-single-ref-ordered.txt
new file mode 100644
index 0000000..2084c36
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-ordered.txt
@@ -0,0 +1,39 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>
+Cc: Dev Eloper2 <dev-eloper2@example.com>
+Cc: Some List <list-1@lists.example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single-ref-sloppy.txt b/tests/samples/trailers-followup-single-ref-sloppy.txt
new file mode 100644
index 0000000..9b6a49d
--- /dev/null
+++ b/tests/samples/trailers-followup-single-ref-sloppy.txt
@@ -0,0 +1,37 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH] Simple test
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+Reviewed-by: Mismatched Reviewer1 <mismatched-reviewer1@example.net>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-single.mbox b/tests/samples/trailers-followup-single.mbox
new file mode 100644
index 0000000..b12f6ba
--- /dev/null
+++ b/tests/samples/trailers-followup-single.mbox
@@ -0,0 +1,78 @@
+From foo@z Thu Jan 1 00:00:00 1970
+From: Test Test <test@example.com>
+Subject: [PATCH] Simple test
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>,
+ Dev Eloper2 <dev-eloper2@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <orig-message@example.com>
+
+Follow-up trailer collating test.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer1 <followup-reviewer1@example.com>
+Subject: Re: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-1@example.com>
+In-Reply-To: <orig-message@example.com>
+References: <orig-message@example.com>
+
+> This is a simple trailer parsing test.
+
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+
+--
+My sig
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer2 <followup-reviewer2@example.com>
+Subject: Re: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-2@example.com>
+In-Reply-To: <fwup-message-1@example.com>
+References: <orig-message@example.com> <fwup-message-1@example.com>
+
+>> This is a simple trailer parsing test.
+>
+> Reviewed-by: Followup Reviewer1 <reviewer1@example.com>
+
+Tested-by: Followup Reviewer2 <followup-reviewer2@example.com>
+
+--
+My sig
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Mismatched Reviewer <mismatched-reviewer1@example.com>
+Subject: Re: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-3@example.com>
+In-Reply-To: <orig-message@example.com>
+References: <orig-message@example.com>
+
+> This is a simple trailer parsing test.
+
+Reviewed-by: Mismatched Reviewer1 <mismatched-reviewer1@example.net>
+
+--
+My sig
+
diff --git a/tests/samples/trailers-followup-with-cover-ref-covertrailers.txt b/tests/samples/trailers-followup-with-cover-ref-covertrailers.txt
new file mode 100644
index 0000000..8a503ea
--- /dev/null
+++ b/tests/samples/trailers-followup-with-cover-ref-covertrailers.txt
@@ -0,0 +1,75 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH v2 1/2] Simple test 1
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-1-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test patch 1.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Coverletter Reviewer1 <followup-reviewer1@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH v2 2/2] Simple test 2
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-2-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test patch 2.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Reviewed-by: Coverletter Reviewer1 <followup-reviewer1@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/bupkes.py b/b4/bupkes.py
+index 12345678..23456789 100644
+--- a/b4/bupkes.py
+--- b/b4/bupkes.py
+@@@ -1,1 +1,1 @@ def bupkes():
+
+
+-bupkes1
++bupkes2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-with-cover-ref-defaults.txt b/tests/samples/trailers-followup-with-cover-ref-defaults.txt
new file mode 100644
index 0000000..cbd1eb8
--- /dev/null
+++ b/tests/samples/trailers-followup-with-cover-ref-defaults.txt
@@ -0,0 +1,73 @@
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH v2 1/2] Simple test 1
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-1-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test patch 1.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
+From git@z Thu Jan 1 00:00:00 1970
+Subject: [PATCH v2 2/2] Simple test 2
+From: Test Test <test@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-2-message@example.com>
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>, Dev Eloper2 <dev-eloper2@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 7bit
+
+Follow-up trailer collating test patch 2.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+Signed-off-by: Test Override <test-override@example.com>
+---
+
+diff --git a/b4/bupkes.py b/b4/bupkes.py
+index 12345678..23456789 100644
+--- a/b4/bupkes.py
+--- b/b4/bupkes.py
+@@@ -1,1 +1,1 @@ def bupkes():
+
+
+-bupkes1
++bupkes2
+
+
+--
+2.wong.fu
+
diff --git a/tests/samples/trailers-followup-with-cover.mbox b/tests/samples/trailers-followup-with-cover.mbox
new file mode 100644
index 0000000..52c14c4
--- /dev/null
+++ b/tests/samples/trailers-followup-with-cover.mbox
@@ -0,0 +1,113 @@
+From foo@z Thu Jan 1 00:00:00 1970
+From: Test Test <test@example.com>
+Subject: [PATCH v2 0/2] Simple cover
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>,
+ Dev Eloper2 <dev-eloper2@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <cover-message@example.com>
+
+This is a cover letter. It has a diffstat.
+
+---
+b4/junk.py | 1 -
+b4/bupkes.py | 1 -
+2 files changed, 2 insertions(+), 2 deletions(-)
+
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Test Test <test@example.com>
+Subject: [PATCH v2 1/2] Simple test 1
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>,
+ Dev Eloper2 <dev-eloper2@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-1-message@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+
+Follow-up trailer collating test patch 1.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Test Test <test@example.com>
+Subject: [PATCH v2 2/2] Simple test 2
+To: Some List <list-1@lists.example.com>
+Cc: Dev Eloper1 <dev-eloper1@example.com>,
+ Dev Eloper2 <dev-eloper2@example.com>
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <patch-2-message@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+
+Follow-up trailer collating test patch 2.
+
+Fixes: abcdef01234567890
+Reviewed-by: Original Reviewer <original-reviewer@example.com>
+Link: https://msgid.link/some@msgid.here
+Signed-off-by: Original Submitter <original-submitter@example.com>
+---
+
+diff --git a/b4/bupkes.py b/b4/bupkes.py
+index 12345678..23456789 100644
+--- a/b4/bupkes.py
+--- b/b4/bupkes.py
+@@@ -1,1 +1,1 @@ def bupkes():
+
+
+-bupkes1
++bupkes2
+
+
+--
+2.wong.fu
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer1 <followup-reviewer1@example.com>
+Subject: Re: [PATCH v2 2/2] Simple test 2
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-1@example.com>
+In-Reply-To: <patch-2-message@example.com>
+References: <patch-2-message@example.com> <cover-message@example.com>
+
+> This is a simple trailer parsing test.
+
+Reviewed-by: Followup Reviewer1 <followup-reviewer1@example.com>
+
+--
+My sig
+
+From foo@z Thu Jan 1 00:00:00 1970
+From: Followup Reviewer1 <followup-reviewer1@example.com>
+Subject: Re: [PATCH v2 0/2] Simple cover
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+Message-Id: <fwup-message-2@example.com>
+In-Reply-To: <cover-message@example.com>
+References: <cover-message@example.com>
+
+> This is a simple trailer parsing test.
+
+Reviewed-by: Coverletter Reviewer1 <followup-reviewer1@example.com>
+
+--
+My sig
+
diff --git a/tests/samples/trailers-test-extinfo.txt b/tests/samples/trailers-test-extinfo.txt
new file mode 100644
index 0000000..d36abbb
--- /dev/null
+++ b/tests/samples/trailers-test-extinfo.txt
@@ -0,0 +1,29 @@
+From: Test Test <test@example.com>
+Subject: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+
+This is a simple trailer parsing test.
+
+Reviewed-by: Bogus Bupkes <bogus@example.com>
+[for the parts that are bogus]
+Fixes: abcdef01234567890
+Tested-by: Some Person <bogus2@example.com>
+ [this person visually indented theirs]
+Link: https://msgid.link/some@msgid.here # initial submission
+Signed-off-by: Wrapped Persontrailer
+<broken@example.com>
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
diff --git a/tests/samples/trailers-test-simple.txt b/tests/samples/trailers-test-simple.txt
new file mode 100644
index 0000000..693d781
--- /dev/null
+++ b/tests/samples/trailers-test-simple.txt
@@ -0,0 +1,24 @@
+From: Test Test <test@example.com>
+Subject: [PATCH] Simple test
+Date: Tue, 30 Aug 2022 11:19:07 -0400
+
+This is a simple trailer parsing test.
+
+Reviewed-by: Bogus Bupkes <bogus@example.com>
+Fixes: abcdef01234567890
+Link: https://msgid.link/some@msgid.here
+---
+
+diff --git a/b4/junk.py b/b4/junk.py
+index 12345678..23456789 100644
+--- a/b4/junk.py
+--- b/b4/junk.py
+@@@ -1,1 +1,1 @@ def junk():
+
+
+-junk1
++junk2
+
+
+--
+2.wong.fu
diff --git a/tests/test___init__.py b/tests/test___init__.py
index d78667e..f97e166 100644
--- a/tests/test___init__.py
+++ b/tests/test___init__.py
@@ -1,7 +1,9 @@
import pytest # noqa
import b4
-import re
import os
+import email
+import mailbox
+import io
@pytest.mark.parametrize('source,expected', [
@@ -25,7 +27,6 @@ def test_save_git_am_mbox(tmpdir, source, regex, flags, ismbox):
import re
if source is not None:
if ismbox:
- import mailbox
mbx = mailbox.mbox(f'tests/samples/{source}.txt')
msgs = list(mbx)
else:
@@ -48,3 +49,64 @@ def test_save_git_am_mbox(tmpdir, source, regex, flags, ismbox):
with open(dest, 'r') as fh:
res = fh.read()
assert re.search(regex, res, flags=flags)
+
+
+@pytest.mark.parametrize('source,expected', [
+ ('trailers-test-simple',
+ [('person', 'Reviewed-By', 'Bogus Bupkes <bogus@example.com>', None),
+ ('utility', 'Fixes', 'abcdef01234567890', None),
+ ('utility', 'Link', 'https://msgid.link/some@msgid.here', None),
+ ]),
+ ('trailers-test-extinfo',
+ [('person', 'Reviewed-by', 'Bogus Bupkes <bogus@example.com>', '[for the parts that are bogus]'),
+ ('utility', 'Fixes', 'abcdef01234567890', None),
+ ('person', 'Tested-by', 'Some Person <bogus2@example.com>', ' [this person visually indented theirs]'),
+ ('utility', 'Link', 'https://msgid.link/some@msgid.here', ' # initial submission'),
+ ('person', 'Signed-off-by', 'Wrapped Persontrailer <broken@example.com>', None),
+ ]),
+])
+def test_parse_trailers(source, expected):
+ with open(f'tests/samples/{source}.txt', 'r') as fh:
+ msg = email.message_from_file(fh)
+ lmsg = b4.LoreMessage(msg)
+ gh, m, trs, bas, sig = b4.LoreMessage.get_body_parts(lmsg.body)
+ assert len(expected) == len(trs)
+ for tr in trs:
+ mytype, myname, myvalue, myextinfo = expected.pop(0)
+ mytr = b4.LoreTrailer(name=myname, value=myvalue, extinfo=myextinfo)
+ assert tr == mytr
+ assert tr.type == mytype
+
+
+@pytest.mark.parametrize('source,serargs,amargs,reference,b4cfg', [
+ ('single', {}, {}, 'defaults', {}),
+ ('single', {}, {'noaddtrailers': True}, 'noadd', {}),
+ ('single', {}, {'addmysob': True}, 'addmysob', {}),
+ ('single', {}, {'addmysob': True, 'copyccs': True}, 'copyccs', {}),
+ ('single', {}, {'addmysob': True, 'addlink': True}, 'addlink', {}),
+ ('single', {}, {'addmysob': True, 'copyccs': True}, 'ordered',
+ {'trailer-order': 'Cc,Tested*,Reviewed*,*'}),
+ ('single', {'sloppytrailers': True}, {'addmysob': True}, 'sloppy', {}),
+ ('with-cover', {}, {'addmysob': True}, 'defaults', {}),
+ ('with-cover', {}, {'covertrailers': True, 'addmysob': True}, 'covertrailers', {}),
+ ('custody', {}, {'addmysob': True, 'copyccs': True}, 'unordered', {}),
+ ('custody', {}, {'addmysob': True, 'copyccs': True}, 'ordered',
+ {'trailer-order': 'Cc,Fixes*,Link*,Suggested*,Reviewed*,Tested*,*'}),
+])
+def test_followup_trailers(source, serargs, amargs, reference, b4cfg):
+ b4.USER_CONFIG = {
+ 'name': 'Test Override',
+ 'email': 'test-override@example.com',
+ }
+ b4.MAIN_CONFIG = dict(b4.DEFAULT_CONFIG)
+ b4.MAIN_CONFIG.update(b4cfg)
+ lmbx = b4.LoreMailbox()
+ for msg in mailbox.mbox(f'tests/samples/trailers-followup-{source}.mbox'):
+ lmbx.add_message(msg)
+ lser = lmbx.get_series(**serargs)
+ assert lser is not None
+ amsgs = lser.get_am_ready(**amargs)
+ ifh = io.StringIO()
+ b4.save_git_am_mbox(amsgs, ifh)
+ with open(f'tests/samples/trailers-followup-{source}-ref-{reference}.txt', 'r') as fh:
+ assert ifh.getvalue() == fh.read()