git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	Duy Nguyen <pclouds@gmail.com>,
	Git Mailing List <git@vger.kernel.org>,
	Ramkumar Ramachandra <artagnon@gmail.com>,
	Jonathan Nieder <jrnieder@gmail.com>,
	Stephen Boyd <bebarino@gmail.com>,
	Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 2/3] test: improve rebase -q test
Date: Mon, 10 Jun 2013 19:27:08 +0200	[thread overview]
Message-ID: <20130610172708.GH2091@goldbirke> (raw)
In-Reply-To: <7vppvuj6wl.fsf@alter.siamese.dyndns.org>

On Mon, Jun 10, 2013 at 08:56:58AM -0700, Junio C Hamano wrote:
> SZEDER Gábor <szeder@ira.uka.de> writes:
> 
> > On Sun, Jun 09, 2013 at 03:41:54PM -0500, Felipe Contreras wrote:
> >> There
> >> will not be a need for test_string_must_be_empty() just like there's
> >> no need for test_string_cmp().
> >
> > Actually, if there were a test_string_cmp(), that would be the test
> > helper function I used most often.
> 
> Hmm, there indeed are quite a many "At this point, the variable's
> value must be this" in the test scripts.  With things like this:
> 
>     t/t0002-gitfile.sh:     test "$SHA" = "$(git rev-list HEAD)"
> 
> we can go to the trash directory upon seeing a failure to run the
> command used on the RHS, but the value in $SHA is cumbersome to find
> out (either running it under sh -x or insert an extra echo before
> it), so such a helper function may be useful.
> 
> Do you really need a general comparison ("does A sort before B") or
> just equality?  If the latter, test_string_equal (or even
> string_equal) might be a better name for it.

Yeah, I need only equality.  Or at least it would be nice to have.

My main motivation is that, like in your example, in the bash prompt
tests I only have to check a single line of output, but because of
debuggability I always did:

  echo "(master)" >expected
  __git_ps1 >actual
  test_cmp expected actual

With such a helper function this could be reduced to a single line:

  test_string_equal "(master)" "$(__git_ps1)"

without loss of functionality or debuggability, because in case of a
failure it would output something like this (bikesheddable, of
course):

  Error:
    expected: "(master)"
    got: "((deadbeef...))"

And perhaps with a description as an optional third argument to help
identify the failed check if multiple such checks are done in a single
test, e.g. the test_rev_parse() helper in t/t1501-worktree.sh, 'setup:
helper for testing rev-parse', which could be shortened as:

  test_string_equal "$1" "$(git rev-parse --is-bare-repository)" "bare"
  test_string_equal "$2" "$(git rev-parse --is-inside-git-dir)" "gitdir"
  test_string_equal "$3" "$(git rev-parse --is-inside-work-tree)" "worktree"

and if something goes wrong we'd get:

  Error: worktree
    expected: "true"
    got: "false"

Perhaps I could find some time in the days ahead to give it a go.


Gábor

  parent reply	other threads:[~2013-06-10 17:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 20:32 [PATCH 0/3] Trivial patches Felipe Contreras
2013-06-07 20:32 ` [PATCH 1/3] sequencer: trivial fix Felipe Contreras
2013-06-07 22:49   ` Junio C Hamano
2013-06-07 22:59     ` Felipe Contreras
2013-06-07 20:32 ` [PATCH 2/3] test: improve rebase -q test Felipe Contreras
2013-06-08  2:44   ` Duy Nguyen
2013-06-08 10:15     ` Felipe Contreras
2013-06-09 18:30     ` Junio C Hamano
2013-06-09 18:35       ` Felipe Contreras
2013-06-09 19:20         ` Junio C Hamano
2013-06-09 19:33           ` Felipe Contreras
2013-06-09 20:35             ` Junio C Hamano
2013-06-09 20:41               ` Felipe Contreras
2013-06-10  9:39                 ` SZEDER Gábor
2013-06-10 15:56                   ` Junio C Hamano
2013-06-10 17:01                     ` Felipe Contreras
2013-06-10 17:27                     ` SZEDER Gábor [this message]
2013-06-10 19:07                       ` Johannes Sixt
2013-06-10 20:19                         ` SZEDER Gábor
2013-06-10 19:17                       ` Junio C Hamano
2013-06-09 22:44             ` Philip Oakley
2013-06-09 23:39               ` Junio C Hamano
2013-06-10 20:41       ` Jeff King
2013-06-07 20:32 ` [PATCH 3/3] submodule: remove unnecessary check Felipe Contreras

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20130610172708.GH2091@goldbirke \
    --to=szeder@ira.uka.de \
    --cc=Jens.Lehmann@web.de \
    --cc=artagnon@gmail.com \
    --cc=bebarino@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).