git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Will Palmer <wmpalmer@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
	raa.lkml@gmail.com, jrnieder@gmail.com
Subject: Re: [PATCH v3 1/5] pretty: add conditional %C?colorname placeholders
Date: Sat, 01 May 2010 20:12:45 -0700	[thread overview]
Message-ID: <7vvdb7yp1u.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 1272656128-2002-2-git-send-email-wmpalmer@gmail.com

Will Palmer <wmpalmer@gmail.com> writes:

> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> new file mode 100755
> index 0000000..b7ec943
> --- /dev/null
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -0,0 +1,52 @@
> +#!/bin/sh
> +#
> +# Released into Public Domain by Will Palmer 2010
> +#

Hmm...

> +test_description='Test pretty formats'
> +. ./test-lib.sh
> +
> +test_expect_success "set up basic repos" \
> +	">foo &&
> +	>bar &&
> +	git add foo &&
> +	test_tick &&
> +	git commit -m initial &&
> +	git add bar &&
> +	test_tick &&
> +	git commit -m 'add bar'"

Just a style thing, but it is easier to read to write:

        test_expect_success 'set up basic repos' '
                >foo &&
                >bar &&
                ...
        '

> +for flag in false true always; do
> +for color in red green blue reset; do
> +
> +	make_expected="git config --get-color no.such.slot $color >expected"
> +	test_expect_success "%C$color with color.ui $flag" \
> +		"$make_expected &&
> +		git config color.ui $flag &&
> +		git log -1 --pretty=format:'%C$color' > actual &&
> +		test_cmp expected actual"

I would really prefer to see a test that checks output with real contents,
not just "switch to color".  E.g. --format="Title: %C${color}%s%C(normal)"
or something like that.

Also you probably would want to make this one round into a shell function
e.g.

	make_expected ()
        {
        	git config --get-color no.such.slot "$1"
	}

	run_format_test ()
        {
		flag=$1 color=$2
                test_expect_success "%C$color with ..." '
			make_expected $color >expected
                        git config color.ui $flag &&
                        git log -1 --pretty=format:'%C($color)' >actual &&
                        test_cmp expected actual"
                '
                ...
	}

and then run this loop:

	for flag in flase true always
        do
        	for color in red green blue reset
                do
                	run_format_test $flag $color
		done
	done

  reply	other threads:[~2010-05-02  3:13 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-30 19:35 [PATCH v3 0/5] pretty: format aliases Will Palmer
2010-04-30 19:35 ` [PATCH v3 1/5] pretty: add conditional %C?colorname placeholders Will Palmer
2010-05-02  3:12   ` Junio C Hamano [this message]
2010-05-02  9:31     ` Will Palmer
2010-04-30 19:35 ` [PATCH v3 2/5] pretty: make %H/%h/etc respect --abbrev[-commit] Will Palmer
2010-05-02  3:13   ` Junio C Hamano
2010-05-02  4:45     ` Jeff King
2010-05-02  5:33       ` Junio C Hamano
2010-05-02  5:40         ` Jeff King
2010-05-02  7:52         ` Will Palmer
2010-05-02  8:50     ` Will Palmer
2010-05-02  9:11       ` Junio C Hamano
2010-05-02  9:17         ` Jonathan Nieder
2010-04-30 19:35 ` [PATCH v3 3/5] pretty: make it easier to add new formats Will Palmer
2010-04-30 19:35 ` [PATCH v3 4/5] pretty: add infrastructure to allow format aliases Will Palmer
2010-05-02  3:13   ` Junio C Hamano
2010-05-02  9:01     ` Will Palmer
2010-04-30 19:35 ` [PATCH v3 5/5] pretty: add aliases for pretty formats Will Palmer
2010-05-02  3:13   ` Junio C Hamano
2010-05-02  4:47   ` Jeff King
2010-05-02  3:12 ` [PATCH v3 0/5] pretty: format aliases 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=7vvdb7yp1u.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    --cc=raa.lkml@gmail.com \
    --cc=wmpalmer@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.
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).