All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: git@vger.kernel.org, Matthieu Moy <Matthieu.Moy@imag.fr>,
	Ivo Anjo <ivo.anjo@ist.utl.pt>
Subject: Re: [PATCHv2 1/2] t7508: test git status -v
Date: Wed, 04 Mar 2015 13:27:46 -0800	[thread overview]
Message-ID: <xmqqk2yw78rx.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <54F6E716.5050808@drmicha.warpmail.net> (Michael J. Gruber's message of "Wed, 04 Mar 2015 12:05:58 +0100")

Michael J Gruber <git@drmicha.warpmail.net> writes:

>> Ahh, OK.  The way the existing tests prepare 'expect' is "by hand".
>> 
>> So I think what is wrong with this new test is not that relies on
>> the current contents of 'expect', but that it modifies it (imagine
>> being a merge/patch monkey who has to accept this change while a
>> change from somebody else that wants to add another test that relies
>> on the original 'expect' intact and then have to scratch his or her
>> head when the two topics are merged, wondering why the latter test
>> starts failing).
>> 
>> Perhaps
>> 
>> 	( cat expect && git diff --cached ) >expect-with-v &&
>>         git status -v >actual &&
>>         test_cmp expect-with-v actual
>> 
>> or something?
>
> That's what I had first, but the new file shows up as untracked file in
> the status output...

If we step back and wonder why it is not a problem for the test
to create 'expect' and 'output' that are not untracked, what would
we find?

It seems that there are two ways to do this:

 - Spell these out in 'expect' as untracked; or
 - Throw them in .gitignore to be ignored by 'status'.

As some other tests want to see how untracked files appear in the
output, I wonder if throwing expect and output that are already used
in the test, together with the new "expect-with-v" and friends, to a
.gitignore file might not be a better direction to go.

Perhaps such a clean-up effort might begin with something like this
patch?

-- >8 --
t7508: .gitignore 'expect' and 'output' files

These files are used to observe the behaviour of the 'status'
command and if there weren't any such observer, the expected
output from 'status' wouldn't even mention them.

Place them in .gitignore to unclutter the output expected by the
tests.  An added benefit is that future tests can add such files
that are purely for use by the observer, i.e. the tests themselves,
by naming them as expect-foo and/or output-bar.


---

 t/t7508-status.sh | 62 +++++--------------------------------------------------
 1 file changed, 5 insertions(+), 57 deletions(-)

diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 8ed5788..9d944a3 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -320,7 +320,11 @@ EOF
 	test_i18ncmp expect output
 '
 
-rm -f .gitignore
+cat >.gitignore <<\EOF
+.gitignore
+expect*
+output*
+EOF
 
 cat >expect <<\EOF
 ## master
@@ -329,8 +333,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -434,8 +436,6 @@ Untracked files:
 	dir2/modified
 	dir2/untracked
 	dir3/
-	expect
-	output
 	untracked
 
 EOF
@@ -456,8 +456,6 @@ A  dir2/added
 ?? dir2/modified
 ?? dir2/untracked
 ?? dir3/
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -unormal' '
@@ -493,8 +491,6 @@ Untracked files:
 	dir2/untracked
 	dir3/untracked1
 	dir3/untracked2
-	expect
-	output
 	untracked
 
 EOF
@@ -518,8 +514,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -uall' '
@@ -554,8 +548,6 @@ Untracked files:
 	untracked
 	../dir2/modified
 	../dir2/untracked
-	../expect
-	../output
 	../untracked
 
 EOF
@@ -569,8 +561,6 @@ A  ../dir2/added
 ?? untracked
 ?? ../dir2/modified
 ?? ../dir2/untracked
-?? ../expect
-?? ../output
 ?? ../untracked
 EOF
 test_expect_success 'status -s with relative paths' '
@@ -586,8 +576,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -625,8 +613,6 @@ Untracked files:
 	<BLUE>dir1/untracked<RESET>
 	<BLUE>dir2/modified<RESET>
 	<BLUE>dir2/untracked<RESET>
-	<BLUE>expect<RESET>
-	<BLUE>output<RESET>
 	<BLUE>untracked<RESET>
 
 EOF
@@ -647,8 +633,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -676,8 +660,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -694,8 +676,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -755,8 +735,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -772,8 +750,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -798,8 +774,6 @@ Untracked files:
 
 	dir1/untracked
 	dir2/
-	expect
-	output
 	untracked
 
 EOF
@@ -848,8 +822,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -870,8 +842,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary is disabled by default' '
@@ -913,8 +883,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -940,8 +908,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary' '
@@ -964,8 +930,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 no changes added to commit (use "git add" and/or "git commit -a")
@@ -983,8 +947,6 @@ cat >expect <<EOF
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary (clean submodule)' '
@@ -1025,8 +987,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -1080,8 +1040,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -1192,8 +1150,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -1254,8 +1210,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF
@@ -1336,8 +1290,6 @@ cat > expect << EOF
 ;	dir1/untracked
 ;	dir2/modified
 ;	dir2/untracked
-;	expect
-;	output
 ;	untracked
 ;
 EOF
@@ -1369,8 +1321,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 no changes added to commit (use "git add" and/or "git commit -a")
@@ -1400,8 +1350,6 @@ Untracked files:
 	dir1/untracked
 	dir2/modified
 	dir2/untracked
-	expect
-	output
 	untracked
 
 EOF

  reply	other threads:[~2015-03-04 21:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13  8:56 How to prevent empty git commit --amend Ivo Anjo
2015-01-13  8:59 ` Daniel Knittl-Frank
2015-01-13 10:22   ` Ivo Anjo
2015-01-13 11:20     ` Michael J Gruber
2015-01-14 10:00 ` Matthieu Moy
2015-01-14 12:15   ` Ivo Anjo
2015-01-14 12:45     ` Matthieu Moy
2015-01-14 17:27   ` Junio C Hamano
2015-01-14 17:36     ` Junio C Hamano
2015-01-15 16:08       ` [RFC/PATCH] commit/status: show the index-worktree with -v -v Michael J Gruber
2015-01-15 20:11         ` Junio C Hamano
2015-01-15 20:38           ` Junio C Hamano
2015-01-16  8:13           ` Michael J Gruber
2015-03-03 14:16             ` [PATCHv2 0/2] More diffs for commit/status Michael J Gruber
2015-03-03 14:16               ` [PATCHv2 1/2] t7508: test git status -v Michael J Gruber
2015-03-03 21:20                 ` Junio C Hamano
2015-03-03 22:26                   ` Junio C Hamano
2015-03-04 11:05                     ` Michael J Gruber
2015-03-04 21:27                       ` Junio C Hamano [this message]
2015-03-03 14:16               ` [PATCHv2 2/2] commit/status: show the index-worktree diff with -v -v Michael J Gruber
2015-03-03 21:26                 ` Junio C Hamano
2015-03-04 11:11                   ` Michael J Gruber
2015-03-04 21:13                     ` Junio C Hamano
2015-03-05 14:13                       ` [PATCHv3 0/3]More diffs for commit/status Michael J Gruber
2015-03-05 14:13                         ` [PATCHv3 1/3] t7508: .gitignore 'expect' and 'output' files Michael J Gruber
2015-03-05 14:13                         ` [PATCHv3 2/3] t7508: test git status -v Michael J Gruber
2015-03-05 14:13                         ` [PATCHv3 3/3] commit/status: show the index-worktree diff with -v -v Michael J Gruber
2015-03-05 19:25                         ` [PATCHv3 0/3]More diffs for commit/status Junio C Hamano
2015-03-05 20:15                           ` Junio C Hamano
2015-03-05 20:27                             ` 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=xmqqk2yw78rx.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=ivo.anjo@ist.utl.pt \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.