threads / patch / 43631

patch, 2 partsRegression test for "stg mail"

Subject: [StGIT PATCH 2/2] Regression test for "stg mail"

## tl;dr

4 messages between Nov 8, 2006 and Nov 12, 2006. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Catalin Marinas· Nov 8, 2006, 10:12 UTC · lore

Re: [PATCH] Add a MIME-Version header to e-mails

On 08/11/06, Karl Hasselström <kha@treskal.com> wrote:
Show 8 quoted lines
> On 2006-11-08 09:41:33 +0000, Catalin Marinas wrote:
> > It would be great if you can run a test script. I've been thinking
> > more of an "import" test that also checks both the "export" and "mail"
> > commands.
>
> I didn't originally plan to thest the actual e-mail sending, but now
> that I think of it, a simple script listening on a random port,
> pretending to be an SMTP daemon, should be quite simple to set up.

I'm not sure it's worth the hassle. You could just generate an mbox file with "mail" and import it with "import --mbox" (it will hopefully be ready this week). Problems with SMTP would be noticed quickly anyway.

Karl Hasselström· Nov 12, 2006, 21:15 UTC · re: Karl Hasselström · lore

[StGIT PATCH 1/2] Regression test for "stg import"

From: Karl Hasselström <kha@treskal.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 t/t1800-import.sh         |   85 ++++++++++++++++++++++++++++++++++++++
 t/t1800-import/email-8bit |   37 ++++++++++++++++
 t/t1800-import/email-mbox |  102 +++++++++++++++++++++++++++++++++++++++++++++
 t/t1800-import/email-qp   |   37 ++++++++++++++++
 t/t1800-import/git-diff   |   20 +++++++++
 t/t1800-import/gnu-diff   |   19 ++++++++
 t/t1800-import/stg-export |   26 +++++++++++
 7 files changed, 326 insertions(+), 0 deletions(-)
Show changes to 7 files +317 −0

t/t1800-import.sh, t/t1800-import/email-8bit, t/t1800-import/email-mbox, t/t1800-import/email-qp, t/t1800-import/git-diff, t/t1800-import/gnu-diff, t/t1800-import/stg-export

diff --git a/t/t1800-import.sh b/t/t1800-import.sh
new file mode 100755
index 0000000..0c1baa3
--- /dev/null
+++ b/t/t1800-import.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# Copyright (c) 2006 Karl Hasselström
+test_description='Test the import command'
+. ./test-lib.sh
+
+test_expect_success \
+    'Initialize the StGIT repository' \
+    '
+    for x in {do,di,da}{be,bi,bo}{dam,dim,dum}; do
+      echo $x
+    done > foo.txt &&
+    git add foo.txt &&
+    git commit -a -m "initial version" &&
+    stg init
+    '
+
+test_expect_success \
+    'Apply a patch created with "git diff"' \
+    '
+    stg import ../t1800-import/git-diff &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] &&
+    stg delete ..
+    '
+
+test_expect_success \
+    'Apply a patch created with GNU diff' \
+    '
+    stg import ../t1800-import/gnu-diff &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] &&
+    stg delete ..
+    '
+
+test_expect_success \
+    'Apply a patch created with "stg export"' \
+    '
+    stg import ../t1800-import/stg-export &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") == 1 ] &&
+    stg delete ..
+    '
+
+test_expect_success \
+    'Apply a patch from an 8bit-encoded e-mail' \
+    '
+    stg import -m ../t1800-import/email-8bit &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") == 1 ] &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "author Inge Ström <inge@power.com>") == 1 ] &&
+    stg delete ..
+    '
+
+test_expect_success \
+    'Apply a patch from a QP-encoded e-mail' \
+    '
+    stg import -m ../t1800-import/email-qp &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree 030be42660323ff2a1958f9ee79589a4f3fbee2f") == 1 ] &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "author Inge Ström <inge@power.com>") == 1 ] &&
+    stg delete ..
+    '
+
+test_expect_success \
+    'Apply several patches from an mbox file' \
+    '
+    stg import -M ../t1800-import/email-mbox &&
+    [ $(git cat-file -p $(stg id change-1) \
+        | grep -c "tree 401bef82cd9fb403aba18f480a63844416a2e023") == 1 ] &&
+    [ $(git cat-file -p $(stg id change-1) \
+        | grep -c "author Inge Ström <inge@power.com>") == 1 ] &&
+    [ $(git cat-file -p $(stg id change-2) \
+        | grep -c "tree e49dbce010ec7f441015a8c64bce0b99108af4cc") == 1 ] &&
+    [ $(git cat-file -p $(stg id change-2) \
+        | grep -c "author Inge Ström <inge@power.com>") == 1 ] &&
+    [ $(git cat-file -p $(stg id change-3) \
+        | grep -c "tree 166bbaf27a44aee21ba78c98822a741e6f7d78f5") == 1 ] &&
+    [ $(git cat-file -p $(stg id change-3) \
+        | grep -c "author Inge Ström <inge@power.com>") == 1 ] &&
+    stg delete ..
+    '
+
+test_done
diff --git a/t/t1800-import/email-8bit b/t/t1800-import/email-8bit
new file mode 100644
index 0000000..316fe27
--- /dev/null
+++ b/t/t1800-import/email-8bit
@@ -0,0 +1,37 @@
+From: Inge =?utf-8?q?Str=C3=B6m?= <inge@power.com>
+Subject: [PATCH] test patch
+To: Upstream <foo@bar.baz>
+Date: Sat, 11 Nov 2006 11:58:14 +0100
+Message-ID: <20061111105814.23209.46952.stgit@localhost>
+User-Agent: StGIT/0.11
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Inge Ström <inge@power.com>
+---
+
+ foo.txt |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index ad01662..d3cd5b6 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -3,6 +3,7 @@ dobedim
+ dobedum
+ dobidam
+ dobidim
++pum-pöddelipåm
+ dobidum
+ dobodam
+ dobodim
+@@ -20,6 +21,7 @@ dabedam
+ dabedim
+ dabedum
+ dabidam
++pum-däddelidum
+ dabidim
+ dabidum
+ dabodam
+
diff --git a/t/t1800-import/email-mbox b/t/t1800-import/email-mbox
new file mode 100644
index 0000000..e4103e5
--- /dev/null
+++ b/t/t1800-import/email-mbox
@@ -0,0 +1,102 @@
+From nobody Sat Nov 11 12:45:27 2006
+From: Inge =?utf-8?q?Str=C3=B6m?= <inge@power.com>
+Subject: [PATCH 1/3] Change 1
+To: Upstream <foo@bar.baz>
+Date: Sat, 11 Nov 2006 12:45:27 +0100
+Message-ID: <20061111114527.31778.12942.stgit@localhost>
+User-Agent: StGIT/0.11
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+Status: RO
+Content-Length: 304
+Lines: 19
+
+Signed-off-by: Inge Ström <inge@power.com>
+---
+
+ foo.txt |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index ad01662..91527b1 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -7,7 +7,7 @@ dobidum
+ dobodam
+ dobodim
+ dobodum
+-dibedam
++dibedad
+ dibedim
+ dibedum
+ dibidam
+
+From nobody Sat Nov 11 12:45:27 2006
+From: Inge =?utf-8?q?Str=C3=B6m?= <inge@power.com>
+Subject: [PATCH 2/3] Change 2
+To: Upstream <foo@bar.baz>
+Date: Sat, 11 Nov 2006 12:45:27 +0100
+Message-ID: <20061111114527.31778.92851.stgit@localhost>
+In-Reply-To: <20061111114527.31778.12942.stgit@localhost>
+References: <20061111114527.31778.12942.stgit@localhost>
+User-Agent: StGIT/0.11
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+Status: RO
+Content-Length: 296
+Lines: 18
+
+Signed-off-by: Inge Ström <inge@power.com>
+---
+
+ foo.txt |    1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index 91527b1..79922d7 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -18,6 +18,7 @@ dibodim
+ dibodum
+ dabedam
+ dabedim
++dibedam
+ dabedum
+ dabidam
+ dabidim
+
+From nobody Sat Nov 11 12:45:27 2006
+From: Inge =?utf-8?q?Str=C3=B6m?= <inge@power.com>
+Subject: [PATCH 3/3] Change 3
+To: Upstream <foo@bar.baz>
+Date: Sat, 11 Nov 2006 12:45:27 +0100
+Message-ID: <20061111114527.31778.45876.stgit@localhost>
+In-Reply-To: <20061111114527.31778.12942.stgit@localhost>
+References: <20061111114527.31778.12942.stgit@localhost>
+User-Agent: StGIT/0.11
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+Status: RO
+Content-Length: 278
+Lines: 16
+
+Signed-off-by: Inge Ström <inge@power.com>
+---
+
+ foo.txt |    1 -
+ 1 files changed, 0 insertions(+), 1 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index 79922d7..6f978b4 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -24,5 +24,4 @@ dabidam
+ dabidim
+ dabidum
+ dabodam
+-dabodim
+ dabodum
+
diff --git a/t/t1800-import/email-qp b/t/t1800-import/email-qp
new file mode 100644
index 0000000..1a77c57
--- /dev/null
+++ b/t/t1800-import/email-qp
@@ -0,0 +1,37 @@
+From: Inge =?utf-8?q?Str=C3=B6m?= <inge@power.com>
+Subject: [PATCH] test patch
+To: Upstream <foo@bar.baz>
+Date: Sat, 11 Nov 2006 11:58:14 +0100
+Message-ID: <20061111105814.23209.46952.stgit@localhost>
+User-Agent: StGIT/0.11
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+Signed-off-by: Inge Str=C3=B6m <inge@power.com>
+---
+
+ foo.txt |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index ad01662..d3cd5b6 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -3,6 +3,7 @@ dobedim
+ dobedum
+ dobidam
+ dobidim
++pum-p=C3=B6ddelip=C3=A5m
+ dobidum
+ dobodam
+ dobodim
+@@ -20,6 +21,7 @@ dabedam
+ dabedim
+ dabedum
+ dabidam
++pum-d=C3=A4ddelidum
+ dabidim
+ dabidum
+ dabodam
+
diff --git a/t/t1800-import/git-diff b/t/t1800-import/git-diff
new file mode 100644
index 0000000..642e11d
--- /dev/null
+++ b/t/t1800-import/git-diff
@@ -0,0 +1,20 @@
+diff --git a/foo.txt b/foo.txt
+index ad01662..d3cd5b6 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -3,6 +3,7 @@ dobedim
+ dobedum
+ dobidam
+ dobidim
++dabadadash
+ dobidum
+ dobodam
+ dobodim
+@@ -20,6 +21,7 @@ dabedam
+ dabedim
+ dabedum
+ dabidam
++dadadadash
+ dabidim
+ dabidum
+ dabodam
diff --git a/t/t1800-import/gnu-diff b/t/t1800-import/gnu-diff
new file mode 100644
index 0000000..46b338a
--- /dev/null
+++ b/t/t1800-import/gnu-diff
@@ -0,0 +1,19 @@
+diff -Naur old/foo.txt new/foo.txt
+--- old/foo.txt	2006-11-11 11:26:18.000000000 +0100
++++ new/foo.txt	2006-11-11 11:25:18.000000000 +0100
+@@ -3,6 +3,7 @@
+ dobedum
+ dobidam
+ dobidim
++dabadadash
+ dobidum
+ dobodam
+ dobodim
+@@ -20,6 +21,7 @@
+ dabedim
+ dabedum
+ dabidam
++dadadadash
+ dabidim
+ dabidum
+ dabodam
diff --git a/t/t1800-import/stg-export b/t/t1800-import/stg-export
new file mode 100644
index 0000000..ddcfc3e
--- /dev/null
+++ b/t/t1800-import/stg-export
@@ -0,0 +1,26 @@
+test patch
+---
+
+ foo.txt |    2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/foo.txt b/foo.txt
+index ad01662..d3cd5b6 100644
+--- a/foo.txt
++++ b/foo.txt
+@@ -3,6 +3,7 @@ dobedim
+ dobedum
+ dobidam
+ dobidim
++dabadadash
+ dobidum
+ dobodam
+ dobodim
+@@ -20,6 +21,7 @@ dabedam
+ dabedim
+ dabedum
+ dabidam
++dadadadash
+ dabidim
+ dabidum
Karl Hasselström· Nov 12, 2006, 21:15 UTC · re: Karl Hasselström · lore
From: Karl Hasselström <kha@treskal.com>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 t/t1900-mail.sh |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
Show changes to t/t1900-mail.sh +33 −0
diff --git a/t/t1900-mail.sh b/t/t1900-mail.sh
new file mode 100755
index 0000000..6a950b4
--- /dev/null
+++ b/t/t1900-mail.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Copyright (c) 2006 Karl Hasselström
+test_description='Test the mail command'
+. ./test-lib.sh
+
+test_expect_success \
+    'Initialize the StGIT repository' \
+    '
+    for i in 1 2 3 4 5; do
+      touch foo.txt &&
+      echo "line $i" >> foo.txt &&
+      git add foo.txt &&
+      git commit -a -m "Patch $i"
+    done &&
+    stg init &&
+    stg uncommit -n 5 foo
+    '
+
+test_expect_success \
+    'Put all the patches in an mbox' \
+    'stg mail --to="Inge Ström <inge@example.com>" -a -m \
+       -t ../../templates/patchmail.tmpl > mbox0'
+
+test_expect_success \
+    'Import the mbox and compare' \
+    '
+    t1=$(git cat-file -p $(stg id) | grep ^tree)
+    stg pop -a &&
+    stg import -M mbox0 &&
+    t2=$(git cat-file -p $(stg id) | grep ^tree) &&
+    [ "$t1" == "$t2" ]
+    '
+

← back to recent threads