From: Junio C Hamano <gitster@pobox.com>
To: "Gary V. Vaughan" <git@mlists.thewrittenword.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v5 06/18] tests: use "test_cmp", not "diff", when verifying the result
Date: Tue, 01 Jun 2010 21:39:24 -0700 [thread overview]
Message-ID: <7vy6eyoxoj.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: 20100514093751.825924000@mlists.thewrittenword.com
"Gary V. Vaughan" <git@mlists.thewrittenword.com> writes:
> In tests, call test_cmp rather than raw diff where possible (i.e. if
> the output does not go to a pipe), to allow the use of, say, 'cmp'
> when the default 'diff -u' is not compatible with a vendor diff.
>
> When that is not possible, use $DIFF, as set in GIT-BUILD-OPTIONS.
Both are very worthy goal.
> Index: b/t/t0000-basic.sh
> ===================================================================
> --- a/t/t0000-basic.sh
> +++ b/t/t0000-basic.sh
> @@ -280,7 +280,7 @@ $expectfilter >expected <<\EOF
> EOF
> test_expect_success \
> 'validate git diff-files output for a know cache/work tree state.' \
> - 'git diff-files >current && diff >/dev/null -b current expected'
> + 'git diff-files >current && test_cmp current expected >/dev/null'
... and I think we could lose >/dev/null redirection once we rewrite these
using test_cmp, but that can be a separate patch.
> Index: b/t/Makefile
> ===================================================================
> --- a/t/Makefile
> +++ b/t/Makefile
> @@ -6,10 +6,14 @@
> -include ../config.mak
>
> #GIT_TEST_OPTS=--verbose --debug
> +GIT_TEST_CMP ?= $(DIFF)
> SHELL_PATH ?= $(SHELL)
> TAR ?= $(TAR)
> RM ?= rm -f
>
> +# Make sure test-lib.sh uses make's value of GIT_TEST_CMP
> +export GIT_TEST_CMP
> +
> # Shell quote;
> SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
But isn't this a regression? When GIT_TEST_CMP is not defined, we used to
GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
which in turn is used like this:
test_cmp() {
$GIT_TEST_CMP "$@"
}
so people would get a more readable "diff -u" output when GIT_TEST_CMP is
not defined and exported. With your patch we would lose -u everywhere,
no?
Also even if your vendor diff lacks unified context format, I would
presume that it would support good old copied context format with -c, and
it would give us a better readability.
How about doing something like this on top of your patch?
Your 7/18 will instead be setting "GIT_TEST_CMP_USE_COPIED_CONTEXT =
YesPlease" for (hopefully) most of the targets whose native "diff" knows
copied context format, and others will set GIT_TEST_CMP to cmp, perhaps?
---
Makefile | 4 ++++
t/Makefile | 4 ----
t/test-lib.sh | 11 ++++++++++-
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 668dbc9..c8cc9e2 100644
--- a/Makefile
+++ b/Makefile
@@ -1374,6 +1374,10 @@ ifdef USE_NED_ALLOCATOR
COMPAT_OBJS += compat/nedmalloc/nedmalloc.o
endif
+ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
+ export GIT_TEST_CMP_USE_COPIED_CONTEXT
+endif
+
ifeq ($(TCLTK_PATH),)
NO_TCLTK=NoThanks
endif
diff --git a/t/Makefile b/t/Makefile
index 93a6475..25c559b 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -6,14 +6,10 @@
-include ../config.mak
#GIT_TEST_OPTS=--verbose --debug
-GIT_TEST_CMP ?= $(DIFF)
SHELL_PATH ?= $(SHELL)
TAR ?= $(TAR)
RM ?= rm -f
-# Make sure test-lib.sh uses make's value of GIT_TEST_CMP
-export GIT_TEST_CMP
-
# Shell quote;
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
diff --git a/t/test-lib.sh b/t/test-lib.sh
index c582964..a290011 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -63,7 +63,16 @@ export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR
-GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
+
+if test -z "$GIT_TEST_CMP"
+then
+ if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"
+ then
+ GIT_TEST_CMP="$DIFF -c"
+ else
+ GIT_TEST_CMP="$DIFF -u"
+ fi
+fi
# Protect ourselves from common misconfiguration to export
# CDPATH into the environment
next prev parent reply other threads:[~2010-06-02 4:39 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-14 9:31 [PATCH v5 00/18] Portability patches for git-1.7.1 Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 01/18] Makefile: pass CPPFLAGS through to fllow customization Gary V. Vaughan
2010-05-14 9:53 ` Robin H. Johnson
2010-05-14 10:58 ` Gary V. Vaughan
2010-05-14 11:04 ` Robin H. Johnson
2010-05-14 12:01 ` Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 02/18] Rewrite dynamic structure initializations to runtime assignment Gary V. Vaughan
2010-06-02 4:39 ` Junio C Hamano
2010-05-14 9:31 ` [PATCH v5 03/18] Makefile: -lpthread may still be necessary when libc has only pthread stubs Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 04/18] enums: omit trailing comma for portability Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 05/18] Do not use "diff" found on PATH while building and installing Gary V. Vaughan
2010-06-02 4:39 ` Junio C Hamano
2010-05-14 9:31 ` [PATCH v5 06/18] tests: use "test_cmp", not "diff", when verifying the result Gary V. Vaughan
2010-06-02 4:39 ` Junio C Hamano [this message]
2010-05-14 9:31 ` [PATCH v5 07/18] test_cmp: do not use "diff -u" on platforms that lack one Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 08/18] git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 09/18] Makefile: some platforms do not have hstrerror anywhere Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 10/18] Make NO_{INET_NTOP,INET_PTON} configured independently Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 11/18] Some platforms lack socklen_t type Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 12/18] Allow disabling "inline" Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 13/18] inline declaration does not work on AIX Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 14/18] Makefile: SunOS 5.6 portability fix Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 15/18] git-compat-util.h: Irix 6.5 defines sgi but not __sgi Gary V. Vaughan
2010-06-02 1:55 ` [PATCH] git-compat-util.h: use apparently more common __sgi macro to detect SGI IRIX Brandon Casey
2010-06-02 8:43 ` Gary V. Vaughan
2010-06-02 9:56 ` Tor Arntsen
2010-05-14 9:31 ` [PATCH v5 16/18] Makefile: HPUX11 portability fixes Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 17/18] Makefile: HP-UX 10.20 " Gary V. Vaughan
2010-05-14 9:31 ` [PATCH v5 18/18] Makefile: Tru64 portability fix Gary V. Vaughan
2010-05-26 5:56 ` [PATCH v5 00/18] Portability patches for git-1.7.1 Gary V. Vaughan
2010-06-07 15:45 ` Gary V. Vaughan
2010-06-07 18:07 ` Junio C Hamano
2010-06-09 9:37 ` Tor Arntsen
2010-06-11 4:30 ` 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=7vy6eyoxoj.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@mlists.thewrittenword.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).