* [StGit PATCH 0/2] Test+fix for bug 11887 (stg sink)
@ 2008-06-29 22:45 Karl Hasselström
2008-06-29 22:45 ` [StGit PATCH 1/2] Try "stg sink" without applied patches Karl Hasselström
2008-06-29 22:45 ` [StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887) Karl Hasselström
0 siblings, 2 replies; 5+ messages in thread
From: Karl Hasselström @ 2008-06-29 22:45 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Erik Sandberg
This should go on the stable branch, of course.
---
Karl Hasselström (2):
Fix "stg sink" with no applied patches (bug 11887)
Try "stg sink" without applied patches
stgit/commands/sink.py | 8 ++++++--
t/t1501-sink.sh | 28 ++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
create mode 100755 t/t1501-sink.sh
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 5+ messages in thread
* [StGit PATCH 1/2] Try "stg sink" without applied patches
2008-06-29 22:45 [StGit PATCH 0/2] Test+fix for bug 11887 (stg sink) Karl Hasselström
@ 2008-06-29 22:45 ` Karl Hasselström
2008-06-30 7:53 ` Sverre Rabbelier
2008-06-29 22:45 ` [StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887) Karl Hasselström
1 sibling, 1 reply; 5+ messages in thread
From: Karl Hasselström @ 2008-06-29 22:45 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Erik Sandberg
It doesn't work, neither with an implicit nor an explicit patch to
sink. This is bug 11887 in the bug tracker.
(The implicit sink testcase actually passes, but that's just because
the test suite can't distinguish between a program bug and an orderly
abort.)
The test was adapted from the script attached to the bug report,
written by Erik Sandberg.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
t/t1501-sink.sh | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
create mode 100755 t/t1501-sink.sh
diff --git a/t/t1501-sink.sh b/t/t1501-sink.sh
new file mode 100755
index 0000000..3872c4b
--- /dev/null
+++ b/t/t1501-sink.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+test_description='Test "stg sink"'
+
+. ./test-lib.sh
+
+test_expect_success 'Initialize StGit stack' '
+ echo 000 >> x &&
+ git add x &&
+ git commit -m initial &&
+ echo 000 >> y &&
+ git add y &&
+ git commit -m y &&
+ stg init &&
+ stg uncommit &&
+ stg pop
+'
+
+test_expect_success 'sink without applied patches' '
+ ! stg sink
+'
+
+test_expect_failure 'sink a specific patch without applied patches' '
+ stg sink y &&
+ test $(echo $(stg applied)) = "y"
+'
+
+test_done
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887)
2008-06-29 22:45 [StGit PATCH 0/2] Test+fix for bug 11887 (stg sink) Karl Hasselström
2008-06-29 22:45 ` [StGit PATCH 1/2] Try "stg sink" without applied patches Karl Hasselström
@ 2008-06-29 22:45 ` Karl Hasselström
1 sibling, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2008-06-29 22:45 UTC (permalink / raw)
To: Catalin Marinas; +Cc: git, Erik Sandberg
There were two separate things to fix: bail out if we need a current
patch and there isn't one (because there are no applied patches), and
make sure we don't try to pop patches that don't exist.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/sink.py | 8 ++++++--
t/t1501-sink.sh | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/stgit/commands/sink.py b/stgit/commands/sink.py
index 2167d87..d8f79b4 100644
--- a/stgit/commands/sink.py
+++ b/stgit/commands/sink.py
@@ -58,9 +58,13 @@ def func(parser, options, args):
if len(args) > 0:
patches = parse_patches(args, all)
else:
- patches = [ crt_series.get_current() ]
+ current = crt_series.get_current()
+ if not current:
+ raise CmdException('No patch applied')
+ patches = [current]
- crt_series.pop_patch(options.to or oldapplied[0])
+ if oldapplied:
+ crt_series.pop_patch(options.to or oldapplied[0])
push_patches(crt_series, patches)
if not options.nopush:
diff --git a/t/t1501-sink.sh b/t/t1501-sink.sh
index 3872c4b..6af45fe 100755
--- a/t/t1501-sink.sh
+++ b/t/t1501-sink.sh
@@ -20,7 +20,7 @@ test_expect_success 'sink without applied patches' '
! stg sink
'
-test_expect_failure 'sink a specific patch without applied patches' '
+test_expect_success 'sink a specific patch without applied patches' '
stg sink y &&
test $(echo $(stg applied)) = "y"
'
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [StGit PATCH 1/2] Try "stg sink" without applied patches
2008-06-29 22:45 ` [StGit PATCH 1/2] Try "stg sink" without applied patches Karl Hasselström
@ 2008-06-30 7:53 ` Sverre Rabbelier
2008-06-30 8:44 ` Karl Hasselström
0 siblings, 1 reply; 5+ messages in thread
From: Sverre Rabbelier @ 2008-06-30 7:53 UTC (permalink / raw)
To: Karl Hasselström; +Cc: Catalin Marinas, git, Erik Sandberg
On Mon, Jun 30, 2008 at 12:45 AM, Karl Hasselström <kha@treskal.com> wrote:
> (The implicit sink testcase actually passes, but that's just because
> the test suite can't distinguish between a program bug and an orderly
> abort.)
Yes it can, that's where "test_must_fail" comes in.
<snip>
> +test_expect_success 'sink without applied patches' '
> + test_must_fail stg sink
> +'
> +
Like that.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [StGit PATCH 1/2] Try "stg sink" without applied patches
2008-06-30 7:53 ` Sverre Rabbelier
@ 2008-06-30 8:44 ` Karl Hasselström
0 siblings, 0 replies; 5+ messages in thread
From: Karl Hasselström @ 2008-06-30 8:44 UTC (permalink / raw)
To: sverre; +Cc: Catalin Marinas, git, Erik Sandberg
On 2008-06-30 09:53:22 +0200, Sverre Rabbelier wrote:
> On Mon, Jun 30, 2008 at 12:45 AM, Karl Hasselström <kha@treskal.com> wrote:
>
> > (The implicit sink testcase actually passes, but that's just
> > because the test suite can't distinguish between a program bug and
> > an orderly abort.)
>
> Yes it can, that's where "test_must_fail" comes in.
>
> > +test_expect_success 'sink without applied patches' '
> > + test_must_fail stg sink
> > +'
> > +
>
> Like that.
Well, except that
1. test_must_fail doesn't even exist in StGit's test-lib.sh, because
I've omitted it on purpose when stealing good stuff from git's
test-lib.sh, because
2. StGit is written in Python, so random bugs virtually never cause
segfaults and stuff, they just raise various exceptions.
That said, StGit (especially in the master branch -- but this patch
was against stable, where this is much less true) does exit with
different exit codes depending on what kind of exception interrupted
the program, and all exceptions not on a certain list cause it to exit
with an exit code that means there's a bug (see the end of
stgit/main.py for details). So writing a test_must_fail with sane
behavior is perfectly doable and not actually all that hard.
Patch? :-)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-30 8:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-29 22:45 [StGit PATCH 0/2] Test+fix for bug 11887 (stg sink) Karl Hasselström
2008-06-29 22:45 ` [StGit PATCH 1/2] Try "stg sink" without applied patches Karl Hasselström
2008-06-30 7:53 ` Sverre Rabbelier
2008-06-30 8:44 ` Karl Hasselström
2008-06-29 22:45 ` [StGit PATCH 2/2] Fix "stg sink" with no applied patches (bug 11887) Karl Hasselström
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).