# [StGit PATCH] Added test case for stg refresh

8 messages from 2007-11-21 to 2007-11-22. Participants: David Kågedal, Karl Hasselström, Catalin Marinas.
Thread: https://gitlist.dev/t/10952

## David Kågedal, 2007-11-21 10:35

Subject: [StGit PATCH] Added test case for stg refresh
Message-ID: <87tznfvqb4.fsf@lysator.liu.se>
URL: https://gitlist.dev/e/87tznfvqb4.fsf%40lysator.liu.se

```
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

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, 2007-11-21 10:43

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <87oddnvpzf.fsf@virtutech.se>
URL: https://gitlist.dev/e/87oddnvpzf.fsf%40virtutech.se
In-Reply-To: <87tznfvqb4.fsf@lysator.liu.se>

```
David Kågedal <davidk@lysator.liu.se> writes:

> 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?

>  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, 2007-11-21 23:15

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <20071121231553.GA19422@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20071121231553.GA19422%40diana.vm.bytemark.co.uk
In-Reply-To: <87oddnvpzf.fsf@virtutech.se>

```
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 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, 2007-11-21 23:31

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <b0943d9e0711211531v2f7b9c0bl99033c0bd58971c7@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0711211531v2f7b9c0bl99033c0bd58971c7%40mail.gmail.com
In-Reply-To: <20071121231553.GA19422@diana.vm.bytemark.co.uk>

```
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?

-- 
Catalin

```

## Karl Hasselström, 2007-11-21 23:55

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <20071121235534.GA21008@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20071121235534.GA21008%40diana.vm.bytemark.co.uk
In-Reply-To: <b0943d9e0711211531v2f7b9c0bl99033c0bd58971c7@mail.gmail.com>

```
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, 2007-11-22 07:59

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <871waivhgq.fsf@virtutech.se>
URL: https://gitlist.dev/e/871waivhgq.fsf%40virtutech.se
In-Reply-To: <b0943d9e0711211531v2f7b9c0bl99033c0bd58971c7@mail.gmail.com>

```
"Catalin Marinas" <catalin.marinas@gmail.com> writes:

> 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, 2007-11-22 08:15

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <b0943d9e0711220015r64d1a5c2y25dfa44610864c99@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0711220015r64d1a5c2y25dfa44610864c99%40mail.gmail.com
In-Reply-To: <871waivhgq.fsf@virtutech.se>

```
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?

-- 
Catalin

```

## David Kågedal, 2007-11-22 08:38

Subject: Re: [StGit PATCH] Added test case for stg refresh
Message-ID: <87pry2u131.fsf@lysator.liu.se>
URL: https://gitlist.dev/e/87pry2u131.fsf%40lysator.liu.se
In-Reply-To: <b0943d9e0711220015r64d1a5c2y25dfa44610864c99@mail.gmail.com>

```
"Catalin Marinas" <catalin.marinas@gmail.com> writes:

> 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

```
