From: Elijah Newren Date: Sun, 03 Oct 2010 19:29:40 GMT Subject: Re: [PATCHv5 01/16] test-lib: make test_expect_code a test command Message-ID: In-Reply-To: <20101003141339.GB17084@burratino> I'll have to let Ævar respond to most of these, but two quick items... On Sun, Oct 3, 2010 at 8:13 AM, Jonathan Nieder wrote: > Elijah Newren wrote: > >> --- a/t/README >> +++ b/t/README >> @@ -482,6 +475,15 @@ library for your script to use. >>           'Perl API' \ >>           "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl >> >> + - test_expect_code >> + >> +   Run a git command and ensure that it exits with the given exit >> +   code. For example: >> + >> +     test_expect_success 'Merge with d/f conflicts' ' >> +             test_expect_code 1 git merge "merge msg" B master >> +     ' > > Side note: this helper should be safe to use even for non-git > commands.  "Huh?" you might ask. "But test_must_fail and > test_might_fail..."  Well, the distinction is this: test_must_fail and > test_might_fail rely on details of git's funny exit code conventions > --- e.g., that 130 is not a controlled failure and 129 is one --- > while test_expect_code has simpler, more generally valid semantics. > > But maybe in practice this helper would only be used for git commands > anyway. Perhaps, but I agree that it at least makes sense to be used by other commands, so I'll change the documentation here to replace "git commands" with just "commands". [...] >> +test_expect_code () { >> +     want_code=$1 >> +     shift >> +     "$@" >> +     exit_code=$? >> +     if test $exit_code = $want_code >> +     then >> +             echo >&2 "test_expect_code: command exited with $exit_code: $*" >> +             return 0 > > This makes the tests noisier on success.  I have no strong feelings > either way about that, but it's probably worth mentioning in the commit > message. I added a brief note in the commit mesage, which I'll resend with the fixed-up series in a minute.