From: Ramsay Jones <ramsay@ramsay1•demon.co.uk>
To: Junio C Hamano <gitster@pobox•com>
Cc: Brian Gernhardt <brian@gernhardtsoftware•com>,
Git List <git@vger•kernel.org>,
Thomas Rast <trast@student•ethz.ch>
Subject: Re: Test failures in t4034
Date: Sat, 01 Sep 2012 18:43:41 +0100 [thread overview]
Message-ID: <5042494D.9040401@ramsay1.demon.co.uk> (raw)
In-Reply-To: <7v1uizdhi7.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Ramsay Jones <ramsay@ramsay1•demon.co.uk> writes:
>
[snip]
>> diff --git a/test-regex.c b/test-regex.c
>> new file mode 100644
>> index 0000000..9259985
>> --- /dev/null
>> +++ b/test-regex.c
>> @@ -0,0 +1,35 @@
>> +#include <stdlib.h>
>> +#include <stdio.h>
>> +#include <stdarg.h>
>> +#include <sys/types.h>
>> +#include <regex.h>
>> +
>> +static void die(const char *fmt, ...)
>> +{
>> + va_list p;
>> +
>> + va_start(p, fmt);
>> + vfprintf(stderr, fmt, p);
>> + va_end(p);
>> + fputc('\n', stderr);
>> + exit(128);
>> +}
>
> Looks like a bit of overkill for only two call sites, whose output
> we would never see because it is behind the test, but OK.
Yes, there was a net increase in the line count when I introduced
die(), but the main program flow was less cluttered by error handling.
The net result looked much better, so I thought it was worth it.
What may not be too obvious, however, is that test-regex.c was written
to be independent of git. You should be able to compile the (single) file
on any POSIX system to determine if the system regex routines suffer this
problem. (It was also supposed to be quiet, unless it die()-ed, and
provide the result via the exit code).
Given that I'm now building it as part of git, I should have simply
#included <git-compat-util.h> and used the die() routine from libgit.a
(since I'm now *relying* on test-regex being linked with libgit.a).
>> +int main(int argc, char **argv)
>> +{
>> + char *pat = "[^={} \t]+";
>> + char *str = "={}\nfred";
>> + regex_t r;
>> + regmatch_t m[1];
>> +
>> + if (regcomp(&r, pat, REG_EXTENDED | REG_NEWLINE))
>> + die("failed regcomp() for pattern '%s'", pat);
>> + if (regexec(&r, str, 1, m, 0))
>> + die("no match of pattern '%s' to string '%s'", pat, str);
>> +
>> + /* http://sourceware.org/bugzilla/show_bug.cgi?id=3957 */
>> + if (m[0].rm_so == 3) /* matches '\n' when it should not */
>> + exit(1);
>
> This could be the third call site of die() that tells the user to
> build with NO_REGEX=1. Then "cd t && sh t0070-fundamental.sh -i -v" would
> give that message directly to the user.
Hmm, even without "-i -v", it's *very* clear what is going on, but sure
it wouldn't hurt either. (Also, I wanted to be able to distinguish an exit
via die() from a "test failed" error return).
So, new (tested) version of the patch comming.
ATB,
Ramsay Jones
next prev parent reply other threads:[~2012-09-01 18:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-18 6:03 Test failures in t4034 Brian Gernhardt
2012-08-19 6:12 ` Junio C Hamano
[not found] ` <20449AC5-D068-46CF-B8C4-E0639FB92EF6@gernhardtsoftware.com>
2012-08-19 17:01 ` Junio C Hamano
2012-08-19 14:50 ` Ramsay Jones
2012-08-19 21:36 ` Johannes Sixt
2012-08-20 0:56 ` Junio C Hamano
2012-08-21 18:37 ` Ramsay Jones
2012-08-21 22:09 ` Junio C Hamano
2012-09-01 17:43 ` Ramsay Jones [this message]
2012-09-03 1:53 ` 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=5042494D.9040401@ramsay1.demon.co.uk \
--to=ramsay@ramsay1$(echo .)demon.co.uk \
--cc=brian@gernhardtsoftware$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=gitster@pobox$(echo .)com \
--cc=trast@student$(echo .)ethz.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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