Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-06 Thread Junio C Hamano
Stefan Beller writes: >> + if (!item) >> + ; /* not among entries being checked */ >> + else { >> + if (strcmp((const char *)item->util, buf.buf)) { >> + printf("expected '%s', got '%s'\n", >> +

Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-06 Thread Junio C Hamano
Stefan Beller writes: >> + *colon = '\0'; >> + item = string_list_lookup(expect, buf.buf); >> + *colon = ':'; > > I have been staring at this for a good couple of minutes and wondered if this > low level string manipulation is really the best way to do it

Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-05 Thread Stefan Beller
On Thu, May 5, 2016 at 7:57 PM, Junio C Hamano wrote: > Stefan Beller writes: > >> instead of filtering afterwards, i.e. each strbuf_add is guarded by >> an >> >> if (is_interesting_output(...)) >> strbuf_add(...) > > That's a good approach. > > The implementation gets a bit trickier

Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-05 Thread Junio C Hamano
Stefan Beller writes: > instead of filtering afterwards, i.e. each strbuf_add is guarded by > an > > if (is_interesting_output(...)) > strbuf_add(...) That's a good approach. The implementation gets a bit trickier than the previous one, but it would look like this. Discard 2/3 and

Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-05 Thread Eric Sunshine
On Thu, May 5, 2016 at 8:41 PM, Stefan Beller wrote: > On Thu, May 5, 2016 at 2:50 PM, Junio C Hamano wrote: >> [...] >> But the only thing this test cares about is if "quiet: 3" is in the >> output. We should be able to write the above 18 lines with just >> four lines, like this: >> >>

Re: [PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-05 Thread Stefan Beller
On Thu, May 5, 2016 at 2:50 PM, Junio C Hamano wrote: > Existing tests in t0040 follow a rather verbose pattern: > > cat >expect <<\EOF > boolean: 0 > integer: 0 > magnitude: 0 > timestamp: 0 > string: (not set) > abbrev: 7 > verbose:

[PATCH 3/3] test-parse-options: --expect= option to simplify tests

2016-05-05 Thread Junio C Hamano
Existing tests in t0040 follow a rather verbose pattern: cat >expect <<\EOF boolean: 0 integer: 0 magnitude: 0 timestamp: 0 string: (not set) abbrev: 7 verbose: 0 quiet: 3 dry run: no file: (not set) EO