git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nazri Ramliy <ayiehere@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add test for correct coloring of git log --decoration
Date: Mon, 28 Jun 2010 22:43:07 -0700	[thread overview]
Message-ID: <7vbpaucs2c.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 1277710240-11378-1-git-send-email-ayiehere@gmail.com

Nazri Ramliy <ayiehere@gmail.com> writes:

> I've tried adding 
>
> 	log --decorate --all --oneline --color=always
>
> to t4013-diff-various.sh but it seems a bit out of place because my test only
> test for colors, while no other test in that file test for colors, hence the
> new test file (t4207-log-decoration-colors.sh).

It sounds fine to have these in a separate file.

> diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
> new file mode 100755
> index 0000000..260e71f
> --- /dev/null
> +++ b/t/t4207-log-decoration-colors.sh
> @@ -0,0 +1,70 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2010 Nazri Ramliy
> +#
> +
> +test_description='Test for "git log --decorate" colors
> +'

Let's not expand a single-line description needlessly into a multi-line
one.

> +. ./test-lib.sh
> +
> +test_expect_success setup '
> +  echo foo > foo.txt &&

Indent these with <TAB>, like:

	echo foo >foo.txt &&

> +  git add foo.txt &&
> +  test_tick &&
> +  git commit -m first &&
> +
> +  echo bar > bar.txt &&
> +  git add bar.txt &&
> +  test_tick &&
> +  git commit -m second &&
> +
> +  test_tick &&
> +  EDITOR=cat git tag v1.0 &&

I think "EDITOR=cat" is doubly wrong.  You are not annotating the tag
anyway, so it won't get called, but if you were, you will get something
like this:

	$ EDITOR=cat git tag -a v1.0

	#
        # Write a tag message
        #
        fatal: no tag message?

> +  git clone . local_clone &&
> +  cd local_clone &&

Do not chdir around inside test scripts without having that in a subshell,
as people typically write "cd .." at the very end of a && chain, which may
not be called when anything in between fails, throwing the later tests
into chaos.

In this case your excuse will be that you will run everything after this
point in that local-clone subdirectory, but still this is not a good style
we would want to keep around, risking to be copied by other people who do
not think carefully.

I think the set-up sequence for this test script should probably be
structured like this:

	get_color()
        {
        	git config ...
	}

	test_expect_success setup '
		git config diff.color.commit yellow &&
                ...
                git config color.decorate.HEAD cyan &&

                c_reset=$(get_color reset) &&
                ...
		c_HEAD=$(get_color cyan) &&

        	test_commit A &&
		git clone . other &&
                (
                	cd other &&
                        test_commit A1
		) &&
		git remote add -f other ./other &&
                test_commit B &&
		git tag v1.0 &&
                echo >>A &&
                git stash save Changes to A &&
	'

so that the main test is done inside the top-level directory (you wanted
the clone only because you wanted to have remote tracking branches, not
because you didn't want to touch the top-level directory).

  reply	other threads:[~2010-06-29  5:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-27 20:11 What's cooking in git.git (Jun 2010, #05; Sun, 27) Junio C Hamano
2010-06-28  7:30 ` [PATCH] Add test for correct coloring of git log --decoration Nazri Ramliy
2010-06-29  5:43   ` Junio C Hamano [this message]
2010-06-29  7:47     ` Nazri Ramliy
2010-06-30 20:37       ` 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=7vbpaucs2c.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=ayiehere@gmail.com \
    --cc=git@vger.kernel.org \
    /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).