git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Guillaume Seguin <guillaume@segu.in>
Subject: Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
Date: Wed, 5 Dec 2007 22:02:26 +0100	[thread overview]
Message-ID: <200712052202.27111.jnareb@gmail.com> (raw)
In-Reply-To: <7v7ijsq5zm.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > It would be quite easy I think to add checking if gitweb returns
> > expected HTTP return code (HTTP status). So what is the portable way
> > to check if first line of some output matches given regexp (given fixed
> > string)?
> 
> Huh?  Wouldn't something like this be enough?
> 
> 	>expect.empty &&
> 	cmd >actual.out 2>actual.err &&
>         diff -u expect.empty actual.err &&
>         first=$(sed -e '1q' <actual.out) &&
> 	test "z$first" = "I like it"

Well, actually that is even better idea. We can go for one of the three
levels of HTTP status checking:

1. Check if we got "Status: 200 OK" when we expect it, and not have it
   when we expect other HTTP status, e.g. when requesting nonexistent
   file. The above code is enough for that.

2. We can check if we got expected status number, for example 200 for
   when we expect no error, or 404 when object is not found, or 403
   if there is no such object etc. I was thinking about using this version
   the need to check not full first line, but fragment of it.

3. We can check full first line, for example
     Status: 200 OK
     Status: 403 Forbidden
     Status: 404 Not Found
     Status: 400 Bad Request
   but this might tie gitweb test too tightly with minute details of
   gitweb output. The above code is good for that too.

What do you think, which route we should go in test?
-- 
Jakub Narebski
Poland

  reply	other threads:[~2007-12-05 21:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-01  1:45 [PATCH] gitweb: disambiguate heads and tags withs the same name Jakub Narebski
2007-12-01  1:47 ` [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name Jakub Narebski
2007-12-01  3:06   ` Jakub Narebski
2007-12-05  7:01   ` Junio C Hamano
2007-12-05 10:13     ` Jakub Narebski
2007-12-05 19:46       ` Junio C Hamano
2007-12-05 21:02         ` Jakub Narebski [this message]
2007-12-05 21:14           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200712052202.27111.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=guillaume@segu.in \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).