threads / patch / 10952

patchAdded test case for stg refresh

Subject: [StGit PATCH] Added test case for stg refresh

## tl;dr

8 messages between Nov 21, 2007 and Nov 22, 2007. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

David Kågedal· Nov 21, 2007, 10:35 UTC · lore
Signed-off-by: David Kågedal <davidk@lysator.liu.se>
---

This test case fails on the kha/experimental branch. Using "stg refresh -p <patch>" can cause all sorts of wieirdness, and there is no test case for it.

 t/t2700-refresh.sh |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100755 t/t2700-refresh.sh
Show changes to t/t2700-refresh.sh +65 −0
diff --git a/t/t2700-refresh.sh b/t/t2700-refresh.sh
new file mode 100755
index 0000000..2e7901c
--- /dev/null
+++ b/t/t2700-refresh.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+test_description='Run "stg refresh"'
+
+. ./test-lib.sh
+
+test_expect_success 'Initialize StGit stack' '
+    stg init &&
+    echo expected.txt >> .git/info/exclude &&
+    echo patches.txt >> .git/info/exclude &&
+    stg new p0 -m "base" &&
+    for i in 1 2 3; do
+        echo base >> foo$i.txt &&
+        git add foo$i.txt
+    done
+    stg refresh &&
+    for i in 1 2 3; do
+        stg new p$i -m "foo $i" &&
+        echo "foo $i" >> foo$i.txt &&
+        stg refresh
+    done
+'
+
+cat > expected.txt <<EOF
+p0
+p3
+EOF
+test_expect_success 'Refresh top patch' '
+    echo bar 3 >> foo3.txt &&
+    stg refresh &&
+    stg status &&
+    test -z "$(stg status)" &&
+    stg patches foo3.txt > patches.txt &&
+    diff -u expected.txt patches.txt
+'
+
+cat > expected.txt <<EOF
+p0
+p2
+EOF
+test_expect_success 'Refresh middle patch' '
+    stg status &&
+    echo bar 2 >> foo2.txt &&
+    stg refresh -p p2 &&
+    stg status &&
+    test -z "$(stg status)" &&
+    stg patches foo2.txt > patches.txt &&
+    diff -u expected.txt patches.txt
+'
+
+cat > expected.txt <<EOF
+p0
+p1
+EOF
+test_expect_success 'Refresh bottom patch' '
+    stg status &&
+    echo bar 1 >> foo1.txt &&
+    stg refresh -p p1 &&
+    stg status &&
+    test -z "$(stg status)" &&
+    stg patches foo1.txt > patches.txt &&
+    diff -u expected.txt patches.txt
+'
+
+test_done
-- 
1.5.3.6.740.ge3d12


-- 
David Kågedal
David Kågedal· Nov 21, 2007, 10:43 UTC · re: David Kågedal · lore

Re: [StGit PATCH] Added test case for stg refresh

David Kågedal <davidk@lysator.liu.se> writes:
Show 6 quoted lines
> Signed-off-by: David Kågedal <davidk@lysator.liu.se>
> ---
>
> This test case fails on the kha/experimental branch.  Using "stg
> refresh -p <patch>" can cause all sorts of wieirdness, and there is no
> test case for it.

I just checked, and it fails on kha/safe as well. So maybe there is some problem with the test case, but I don't know what it is.

And maybe it should be called t2301 instead?
Show 77 quoted lines
>  t/t2700-refresh.sh |   65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 65 insertions(+), 0 deletions(-)
>  create mode 100755 t/t2700-refresh.sh
>
> diff --git a/t/t2700-refresh.sh b/t/t2700-refresh.sh
> new file mode 100755
> index 0000000..2e7901c
> --- /dev/null
> +++ b/t/t2700-refresh.sh
> @@ -0,0 +1,65 @@
> +#!/bin/sh
> +
> +test_description='Run "stg refresh"'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'Initialize StGit stack' '
> +    stg init &&
> +    echo expected.txt >> .git/info/exclude &&
> +    echo patches.txt >> .git/info/exclude &&
> +    stg new p0 -m "base" &&
> +    for i in 1 2 3; do
> +        echo base >> foo$i.txt &&
> +        git add foo$i.txt
> +    done
> +    stg refresh &&
> +    for i in 1 2 3; do
> +        stg new p$i -m "foo $i" &&
> +        echo "foo $i" >> foo$i.txt &&
> +        stg refresh
> +    done
> +'
> +
> +cat > expected.txt <<EOF
> +p0
> +p3
> +EOF
> +test_expect_success 'Refresh top patch' '
> +    echo bar 3 >> foo3.txt &&
> +    stg refresh &&
> +    stg status &&
> +    test -z "$(stg status)" &&
> +    stg patches foo3.txt > patches.txt &&
> +    diff -u expected.txt patches.txt
> +'
> +
> +cat > expected.txt <<EOF
> +p0
> +p2
> +EOF
> +test_expect_success 'Refresh middle patch' '
> +    stg status &&
> +    echo bar 2 >> foo2.txt &&
> +    stg refresh -p p2 &&
> +    stg status &&
> +    test -z "$(stg status)" &&
> +    stg patches foo2.txt > patches.txt &&
> +    diff -u expected.txt patches.txt
> +'
> +
> +cat > expected.txt <<EOF
> +p0
> +p1
> +EOF
> +test_expect_success 'Refresh bottom patch' '
> +    stg status &&
> +    echo bar 1 >> foo1.txt &&
> +    stg refresh -p p1 &&
> +    stg status &&
> +    test -z "$(stg status)" &&
> +    stg patches foo1.txt > patches.txt &&
> +    diff -u expected.txt patches.txt
> +'
> +
> +test_done
> -- 
> 1.5.3.6.740.ge3d12
-- 
David Kågedal, Virtutech
Karl Hasselström· Nov 21, 2007, 23:15 UTC · re: David Kågedal · lore

Re: [StGit PATCH] Added test case for stg refresh

On 2007-11-21 11:43:00 +0100, David Kågedal wrote:
Show 8 quoted lines
> David Kågedal <davidk@lysator.liu.se> writes:
>
> > This test case fails on the kha/experimental branch. Using "stg
> > refresh -p <patch>" can cause all sorts of wieirdness, and there
> > is no test case for it.
>
> I just checked, and it fails on kha/safe as well. So maybe there is
> some problem with the test case, but I don't know what it is.

Thanks, more tests are always welcome. But it doesn't fail for me. I've just pushed out updated kha/safe and kha/experimental branches -- with this new test at the bottom of the stack -- and the whole test suite passes at every step. Could you try the updated branches and see if you can still make it fail?

> And maybe it should be called t2301 instead?

Those numbers are just one big jumble anyway, so no need to bother. :-)

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Catalin Marinas· Nov 21, 2007, 23:31 UTC · re: Karl Hasselström · lore

Re: [StGit PATCH] Added test case for stg refresh

On 21/11/2007, Karl Hasselström <kha@treskal.com> wrote:
Show 7 quoted lines
> On 2007-11-21 11:43:00 +0100, David Kågedal wrote:
>
> > David Kågedal <davidk@lysator.liu.se> writes:
> >
> > > This test case fails on the kha/experimental branch. Using "stg
> > > refresh -p <patch>" can cause all sorts of wieirdness, and there
> > > is no test case for it.

I noticed the weirdness few days ago and fixed it in e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it). Do you still see problems after this commit?

-- 
Catalin
Karl Hasselström· Nov 21, 2007, 23:55 UTC · re: Catalin Marinas · lore

Re: [StGit PATCH] Added test case for stg refresh

On 2007-11-21 23:31:45 +0000, Catalin Marinas wrote:
> I noticed the weirdness few days ago and fixed it in
> e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
> Do you still see problems after this commit?
Confirmed: the test fails before e8813959, and succeeds afterwards.
(You can pull the test from
  git://repo.or.cz/stgit/kha.git safe
if you like.)
-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
David Kågedal· Nov 22, 2007, 07:59 UTC · re: Catalin Marinas · lore

Re: [StGit PATCH] Added test case for stg refresh

"Catalin Marinas" <catalin.marinas@gmail.com> writes:
Show 12 quoted lines
> On 21/11/2007, Karl Hasselström <kha@treskal.com> wrote:
>> On 2007-11-21 11:43:00 +0100, David Kågedal wrote:
>>
>> > David Kågedal <davidk@lysator.liu.se> writes:
>> >
>> > > This test case fails on the kha/experimental branch. Using "stg
>> > > refresh -p <patch>" can cause all sorts of wieirdness, and there
>> > > is no test case for it.
>
> I noticed the weirdness few days ago and fixed it in
> e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
> Do you still see problems after this commit?

The problem I see is that there still is no test case. That is bad and means that it could break again tomorrow without anyone noticing.

Luckily, I just wrote one for you :-)
-- 
David Kågedal
Catalin Marinas· Nov 22, 2007, 08:15 UTC · re: David Kågedal · lore

Re: [StGit PATCH] Added test case for stg refresh

On 22/11/2007, David Kågedal <davidk@lysator.liu.se> wrote:
Show 9 quoted lines
> "Catalin Marinas" <catalin.marinas@gmail.com> writes:
> > I noticed the weirdness few days ago and fixed it in
> > e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
> > Do you still see problems after this commit?
>
> The problem I see is that there still is no test case. That is bad and
> means that it could break again tomorrow without anyone noticing.
>
> Luckily, I just wrote one for you :-)

Thanks :-). We are still far from testing all the possible combinations. Is there a way to do code coverage in Python?

-- 
Catalin
David Kågedal· Nov 22, 2007, 08:38 UTC · re: Catalin Marinas · lore

Re: [StGit PATCH] Added test case for stg refresh

"Catalin Marinas" <catalin.marinas@gmail.com> writes:
Show 13 quoted lines
> On 22/11/2007, David Kågedal <davidk@lysator.liu.se> wrote:
>> "Catalin Marinas" <catalin.marinas@gmail.com> writes:
>> > I noticed the weirdness few days ago and fixed it in
>> > e8813959aa3a7c41ffef61d06068b10519bd4830 (though no test caught it).
>> > Do you still see problems after this commit?
>>
>> The problem I see is that there still is no test case. That is bad and
>> means that it could break again tomorrow without anyone noticing.
>>
>> Luckily, I just wrote one for you :-)
>
> Thanks :-). We are still far from testing all the possible
> combinations. Is there a way to do code coverage in Python?

Being far from testing everything doesn't mean that you can't start adding tests for the things you know have a tendency to break. And for the things that you are going to refactor. And as regression tests when you fix a bug. A test suite can be built up by adding small parts at a time.

But no, I don't know of any useful code coverage tool for python, but I haven't really looked.

-- 
David Kågedal

← back to recent threads