* [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-04 1:19 git-cvsserver test failures (still) Frank Lichtenheld
@ 2007-10-04 1:43 ` Brian Gernhardt
0 siblings, 0 replies; 13+ messages in thread
From: Brian Gernhardt @ 2007-10-04 1:43 UTC (permalink / raw)
To: git
This was causing test failures because die was exiting 255.
---
This finally takes care of my test failures.
git-cvsserver.perl | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 13dbd27..0d55fec 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -145,8 +145,10 @@ if ($state->{method} eq 'pserver') {
}
my $request = $1;
$line = <STDIN>; chomp $line;
- req_Root('root', $line) # reuse Root
- or die "E Invalid root $line \n";
+ unless (req_Root('root', $line)) { # reuse Root
+ print "E Invalid root $line \n";
+ exit 1;
+ }
$line = <STDIN>; chomp $line;
unless ($line eq 'anonymous') {
print "E Only anonymous user allowed via pserver\n";
--
1.5.3.4.203.gcc61a
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH] Use exit 1 instead of die when req_Root fails.
@ 2007-10-17 14:05 Brian Gernhardt
2007-10-17 14:39 ` Morten Welinder
2007-10-17 19:06 ` Frank Lichtenheld
0 siblings, 2 replies; 13+ messages in thread
From: Brian Gernhardt @ 2007-10-17 14:05 UTC (permalink / raw)
To: git, spearce
This was causing test failures because die was exiting 255.
Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
---
Shawn, I sent this in a couple weeks ago but it looks like it never
made it into your repo. It fixes test failures on my machine that have
been plauging me for months.
git-cvsserver.perl | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 13dbd27..0d55fec 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -145,8 +145,10 @@ if ($state->{method} eq 'pserver') {
}
my $request = $1;
$line = <STDIN>; chomp $line;
- req_Root('root', $line) # reuse Root
- or die "E Invalid root $line \n";
+ unless (req_Root('root', $line)) { # reuse Root
+ print "E Invalid root $line \n";
+ exit 1;
+ }
$line = <STDIN>; chomp $line;
unless ($line eq 'anonymous') {
print "E Only anonymous user allowed via pserver\n";
--
1.5.3.4.206.g0cef9
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 14:05 [PATCH] Use exit 1 instead of die when req_Root fails Brian Gernhardt
@ 2007-10-17 14:39 ` Morten Welinder
2007-10-17 15:16 ` Brian Gernhardt
2007-10-17 19:08 ` Frank Lichtenheld
2007-10-17 19:06 ` Frank Lichtenheld
1 sibling, 2 replies; 13+ messages in thread
From: Morten Welinder @ 2007-10-17 14:39 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: git, spearce
> made it into your repo. It fixes test failures on my machine that have
> been plauging me for months.
That sounds more like a reason to fix the test. "die" is the perl
standard way of
reporting an error. It will print the error message on stderr, not on
stdout like
your version does.
IMHO, of course.
Morten
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 14:39 ` Morten Welinder
@ 2007-10-17 15:16 ` Brian Gernhardt
2007-10-17 15:39 ` Lars Hjemli
2007-10-18 18:54 ` Jan Hudec
2007-10-17 19:08 ` Frank Lichtenheld
1 sibling, 2 replies; 13+ messages in thread
From: Brian Gernhardt @ 2007-10-17 15:16 UTC (permalink / raw)
To: Morten Welinder; +Cc: git, spearce
On Oct 17, 2007, at 10:39 AM, Morten Welinder wrote:
>> made it into your repo. It fixes test failures on my machine
>> that have
>> been plauging me for months.
>
> That sounds more like a reason to fix the test. "die" is the perl
> standard way of reporting an error. It will print the error message
> on stderr, not on stdout like your version does.
>
> IMHO, of course.
The problem is that die can exit with varying exit codes, and exit
codes >= 128 make the test suite assume something has gone wrong with
the test. In particular, because $! (errcode) and $? (previous shell
command return) are both 0, it returns 255. Or at least that's how
it works out on my system. I'm not sure why it doesn't do that on
others.
But the test is expecting a failure here and it appears to be failing
in the correct way, just with an error code test-lib.sh doesn't
like. I asked on list the best way to fix it and Frank Lichtenheld
said (and nobody objected until now) that this was the best way to
fix it.
Also, the not printing on STRERR is identical to another section of
code just below mine:
> unless ($line eq 'anonymous') {
> print "E Only anonymous user allowed via pserver\n";
> print "I HATE YOU\n";
> exit 1;
> }
However, amending my patch to print to STDERR is not difficult.
~~ Brian Gernhardt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 15:16 ` Brian Gernhardt
@ 2007-10-17 15:39 ` Lars Hjemli
2007-10-17 18:40 ` Brian Gernhardt
2007-10-18 18:54 ` Jan Hudec
1 sibling, 1 reply; 13+ messages in thread
From: Lars Hjemli @ 2007-10-17 15:39 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Morten Welinder, git, spearce
On 10/17/07, Brian Gernhardt <benji@silverinsanity.com> wrote:
> The problem is that die can exit with varying exit codes, and exit
> codes >= 128 make the test suite assume something has gone wrong with
> the test.
This makes me wonder: what about all the other instances of die() in
git-cvsserver? Or in any of the other perl scripts, for that matter?
Should they all be fixed, or is it this particular test that is wrong?
--
larsh
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 15:39 ` Lars Hjemli
@ 2007-10-17 18:40 ` Brian Gernhardt
2007-10-17 19:27 ` Lars Hjemli
0 siblings, 1 reply; 13+ messages in thread
From: Brian Gernhardt @ 2007-10-17 18:40 UTC (permalink / raw)
To: Lars Hjemli; +Cc: Morten Welinder, git, spearce
I wish I got this much attention the first time I tried to get this
problem fixed. ;-)
On Oct 17, 2007, at 11:39 AM, Lars Hjemli wrote:
> This makes me wonder: what about all the other instances of die() in
> git-cvsserver? Or in any of the other perl scripts, for that matter?
> Should they all be fixed, or is it this particular test that is wrong?
The reason this comes up is because t/test-lib.sh:test_expect_failure
() thinks codes > 128 (or negative values if you want to look at it
that way) are bad tests. I believe this is because many shells use
these codes to indicate things like "command not found" or other
probably unexpected failures.
Other than that, does it matter what die() returns, as long as it's
non-zero?
~~Brian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 14:05 [PATCH] Use exit 1 instead of die when req_Root fails Brian Gernhardt
2007-10-17 14:39 ` Morten Welinder
@ 2007-10-17 19:06 ` Frank Lichtenheld
2007-10-17 19:15 ` Brian Gernhardt
1 sibling, 1 reply; 13+ messages in thread
From: Frank Lichtenheld @ 2007-10-17 19:06 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: git, spearce
On Wed, Oct 17, 2007 at 10:05:47AM -0400, Brian Gernhardt wrote:
> This was causing test failures because die was exiting 255.
>
> Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
> ---
>
> Shawn, I sent this in a couple weeks ago but it looks like it never
> made it into your repo. It fixes test failures on my machine that have
> been plauging me for months.
I have this in my repo and will submit this with the other git-cvsserver
changes. I was just waiting for either Junio to return or someone else
stepping up.
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 14:39 ` Morten Welinder
2007-10-17 15:16 ` Brian Gernhardt
@ 2007-10-17 19:08 ` Frank Lichtenheld
1 sibling, 0 replies; 13+ messages in thread
From: Frank Lichtenheld @ 2007-10-17 19:08 UTC (permalink / raw)
To: Morten Welinder; +Cc: Brian Gernhardt, git, spearce
On Wed, Oct 17, 2007 at 10:39:52AM -0400, Morten Welinder wrote:
> > made it into your repo. It fixes test failures on my machine that have
> > been plauging me for months.
>
> That sounds more like a reason to fix the test. "die" is the perl
> standard way of
> reporting an error. It will print the error message on stderr, not on
> stdout like
> your version does.
Please note that git-cvsserver is special in that its output will never
be displayed directly to the user but is always interpreted first by
the client. So print "E something" is acutally in some cases more
correct than print STDERR something.
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 19:06 ` Frank Lichtenheld
@ 2007-10-17 19:15 ` Brian Gernhardt
2007-10-18 5:04 ` Shawn O. Pearce
0 siblings, 1 reply; 13+ messages in thread
From: Brian Gernhardt @ 2007-10-17 19:15 UTC (permalink / raw)
To: Frank Lichtenheld; +Cc: git, spearce
On Oct 17, 2007, at 3:06 PM, Frank Lichtenheld wrote:
> I have this in my repo and will submit this with the other git-
> cvsserver
> changes. I was just waiting for either Junio to return or someone else
> stepping up.
Ah. I had missed that. I just dug up the patch when switching to
Shawn's repo gave me those old testing errors. Had thought it had
gotten lost in the shuffle.
Never mind me then,
~~ Brian
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 18:40 ` Brian Gernhardt
@ 2007-10-17 19:27 ` Lars Hjemli
0 siblings, 0 replies; 13+ messages in thread
From: Lars Hjemli @ 2007-10-17 19:27 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Morten Welinder, git, spearce
On 10/17/07, Brian Gernhardt <benji@silverinsanity.com> wrote:
> I wish I got this much attention the first time I tried to get this
> problem fixed. ;-)
>
> On Oct 17, 2007, at 11:39 AM, Lars Hjemli wrote:
>
> > This makes me wonder: what about all the other instances of die() in
> > git-cvsserver? Or in any of the other perl scripts, for that matter?
> > Should they all be fixed, or is it this particular test that is wrong?
>
> The reason this comes up is because t/test-lib.sh:test_expect_failure
> () thinks codes > 128 (or negative values if you want to look at it
> that way) are bad tests. I believe this is because many shells use
> these codes to indicate things like "command not found" or other
> probably unexpected failures.
>
> Other than that, does it matter what die() returns, as long as it's
> non-zero?
My point exactly ;-)
If the test is changed to use 'test_expect_success' in the same way as
'req_Root failure (relative pathname)' does it, the test no longer
depends on the exact exit-code returned by die().
IMHO this is much better future-proofing than replacing die() with
print()/exit 1 whenever one of these tests fails.
--
larsh
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 19:15 ` Brian Gernhardt
@ 2007-10-18 5:04 ` Shawn O. Pearce
2007-10-18 13:33 ` Frank Lichtenheld
0 siblings, 1 reply; 13+ messages in thread
From: Shawn O. Pearce @ 2007-10-18 5:04 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Frank Lichtenheld, git
Brian Gernhardt <benji@silverinsanity.com> wrote:
> On Oct 17, 2007, at 3:06 PM, Frank Lichtenheld wrote:
>
> >I have this in my repo and will submit this with the other git-
> >cvsserver
> >changes. I was just waiting for either Junio to return or someone else
> >stepping up.
>
> Ah. I had missed that. I just dug up the patch when switching to
> Shawn's repo gave me those old testing errors. Had thought it had
> gotten lost in the shuffle.
It did. I have your resubmit that started this thread in my INQ and
will try to get to it today. But if Frank has a queue of stuff I've
missed I'd like a pointer to it so I can also try to start working
through it. I know I also have some other topics that Lars Hjemli
accumlated in his tree that I still need to cherry-pick over into
mine, but I don't see the one we are talking about in there.
--
Shawn.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-18 5:04 ` Shawn O. Pearce
@ 2007-10-18 13:33 ` Frank Lichtenheld
0 siblings, 0 replies; 13+ messages in thread
From: Frank Lichtenheld @ 2007-10-18 13:33 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Brian Gernhardt, git
On Thu, Oct 18, 2007 at 01:04:56AM -0400, Shawn O. Pearce wrote:
> Brian Gernhardt <benji@silverinsanity.com> wrote:
> > On Oct 17, 2007, at 3:06 PM, Frank Lichtenheld wrote:
> >
> > >I have this in my repo and will submit this with the other git-
> > >cvsserver
> > >changes. I was just waiting for either Junio to return or someone else
> > >stepping up.
> >
> > Ah. I had missed that. I just dug up the patch when switching to
> > Shawn's repo gave me those old testing errors. Had thought it had
> > gotten lost in the shuffle.
>
> It did. I have your resubmit that started this thread in my INQ and
> will try to get to it today. But if Frank has a queue of stuff I've
> missed I'd like a pointer to it so I can also try to start working
> through it. I know I also have some other topics that Lars Hjemli
> accumlated in his tree that I still need to cherry-pick over into
> mine, but I don't see the one we are talking about in there.
Yeah, I postponed sending it to tomorrow for some days now :/
Anyway, my current queue is visible at
git://source.djpig.de/git/git-cvsserver.git cvsserver
So you can fetch and merge/cherry-pick it yourself if you prefer.
Gruesse,
--
Frank Lichtenheld <frank@lichtenheld.de>
www: http://www.djpig.de/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH] Use exit 1 instead of die when req_Root fails.
2007-10-17 15:16 ` Brian Gernhardt
2007-10-17 15:39 ` Lars Hjemli
@ 2007-10-18 18:54 ` Jan Hudec
1 sibling, 0 replies; 13+ messages in thread
From: Jan Hudec @ 2007-10-18 18:54 UTC (permalink / raw)
To: Brian Gernhardt; +Cc: Morten Welinder, git, spearce
[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]
On Wed, Oct 17, 2007 at 11:16:34 -0400, Brian Gernhardt wrote:
>
> On Oct 17, 2007, at 10:39 AM, Morten Welinder wrote:
>
>>> made it into your repo. It fixes test failures on my machine that have
>>> been plauging me for months.
>>
>> That sounds more like a reason to fix the test. "die" is the perl
>> standard way of reporting an error. It will print the error message
>> on stderr, not on stdout like your version does.
>>
>> IMHO, of course.
>
> The problem is that die can exit with varying exit codes, and exit codes >=
> 128 make the test suite assume something has gone wrong with the test. In
> particular, because $! (errcode) and $? (previous shell command return) are
> both 0, it returns 255. Or at least that's how it works out on my system.
> I'm not sure why it doesn't do that on others.
>
> But the test is expecting a failure here and it appears to be failing in
> the correct way, just with an error code test-lib.sh doesn't like. I asked
> on list the best way to fix it and Frank Lichtenheld said (and nobody
> objected until now) that this was the best way to fix it.
>
> Also, the not printing on STRERR is identical to another section of code
> just below mine:
>
>> unless ($line eq 'anonymous') {
>> print "E Only anonymous user allowed via pserver\n";
>> print "I HATE YOU\n";
>> exit 1;
>> }
>
> However, amending my patch to print to STDERR is not difficult.
Hm. There are two kinds of errors in git-cvsserver and they should be handled
differently.
If the error is an invalid request (like the quoted one), there should be
normal print, to STDOUT, starting with "E", because it's an error message
that should be sent to the client.
On the other hand if the error is internal error in the script or it's
configuration, than the error should probably be reported via die, *without*
E at the begining (it will be prefixed with location anyway). Such message
will probably end up in the log rather than sent to the client.
--
Jan 'Bulb' Hudec <bulb@ucw.cz>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-10-18 18:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-17 14:05 [PATCH] Use exit 1 instead of die when req_Root fails Brian Gernhardt
2007-10-17 14:39 ` Morten Welinder
2007-10-17 15:16 ` Brian Gernhardt
2007-10-17 15:39 ` Lars Hjemli
2007-10-17 18:40 ` Brian Gernhardt
2007-10-17 19:27 ` Lars Hjemli
2007-10-18 18:54 ` Jan Hudec
2007-10-17 19:08 ` Frank Lichtenheld
2007-10-17 19:06 ` Frank Lichtenheld
2007-10-17 19:15 ` Brian Gernhardt
2007-10-18 5:04 ` Shawn O. Pearce
2007-10-18 13:33 ` Frank Lichtenheld
-- strict thread matches above, loose matches on Subject: below --
2007-10-04 1:19 git-cvsserver test failures (still) Frank Lichtenheld
2007-10-04 1:43 ` [PATCH] Use exit 1 instead of die when req_Root fails Brian Gernhardt
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).