git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: "Dennis Kaarsemaker" <dennis@kaarsemaker.net>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 01/16] t1007: factor out repeated setup
Date: Mon, 12 Sep 2016 20:23:12 -0700	[thread overview]
Message-ID: <20160913032312.yheky2o25lmibvmb@sigill.intra.peff.net> (raw)
In-Reply-To: <20160913032242.coyuhyhn6uklewuk@sigill.intra.peff.net>

We have a series of 3 CRLF tests that do exactly the same
(long) setup sequence. Let's pull it out into a common setup
test, which is shorter, more efficient, and will make it
easier to add new tests.

Note that we don't have to worry about cleaning up any of
the setup which was previously per-test; we call pop_repo
after the CRLF tests, which cleans up everything.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t1007-hash-object.sh | 32 ++++++++------------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index 7d2baa1..c89faa6 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -101,7 +101,7 @@ test_expect_success 'git hash-object --stdin file1 <file0 first operates on file
 	test "$obname1" = "$obname1new"
 '
 
-test_expect_success 'check that appropriate filter is invoke when --path is used' '
+test_expect_success 'set up crlf tests' '
 	echo fooQ | tr Q "\\015" >file0 &&
 	cp file0 file1 &&
 	echo "file0 -crlf" >.gitattributes &&
@@ -109,7 +109,10 @@ test_expect_success 'check that appropriate filter is invoke when --path is used
 	git config core.autocrlf true &&
 	file0_sha=$(git hash-object file0) &&
 	file1_sha=$(git hash-object file1) &&
-	test "$file0_sha" != "$file1_sha" &&
+	test "$file0_sha" != "$file1_sha"
+'
+
+test_expect_success 'check that appropriate filter is invoke when --path is used' '
 	path1_sha=$(git hash-object --path=file1 file0) &&
 	path0_sha=$(git hash-object --path=file0 file1) &&
 	test "$file0_sha" = "$path0_sha" &&
@@ -117,38 +120,19 @@ test_expect_success 'check that appropriate filter is invoke when --path is used
 	path1_sha=$(cat file0 | git hash-object --path=file1 --stdin) &&
 	path0_sha=$(cat file1 | git hash-object --path=file0 --stdin) &&
 	test "$file0_sha" = "$path0_sha" &&
-	test "$file1_sha" = "$path1_sha" &&
-	git config --unset core.autocrlf
+	test "$file1_sha" = "$path1_sha"
 '
 
 test_expect_success 'check that --no-filters option works' '
-	echo fooQ | tr Q "\\015" >file0 &&
-	cp file0 file1 &&
-	echo "file0 -crlf" >.gitattributes &&
-	echo "file1 crlf" >>.gitattributes &&
-	git config core.autocrlf true &&
-	file0_sha=$(git hash-object file0) &&
-	file1_sha=$(git hash-object file1) &&
-	test "$file0_sha" != "$file1_sha" &&
 	nofilters_file1=$(git hash-object --no-filters file1) &&
 	test "$file0_sha" = "$nofilters_file1" &&
 	nofilters_file1=$(cat file1 | git hash-object --stdin) &&
-	test "$file0_sha" = "$nofilters_file1" &&
-	git config --unset core.autocrlf
+	test "$file0_sha" = "$nofilters_file1"
 '
 
 test_expect_success 'check that --no-filters option works with --stdin-paths' '
-	echo fooQ | tr Q "\\015" >file0 &&
-	cp file0 file1 &&
-	echo "file0 -crlf" >.gitattributes &&
-	echo "file1 crlf" >>.gitattributes &&
-	git config core.autocrlf true &&
-	file0_sha=$(git hash-object file0) &&
-	file1_sha=$(git hash-object file1) &&
-	test "$file0_sha" != "$file1_sha" &&
 	nofilters_file1=$(echo "file1" | git hash-object --stdin-paths --no-filters) &&
-	test "$file0_sha" = "$nofilters_file1" &&
-	git config --unset core.autocrlf
+	test "$file0_sha" = "$nofilters_file1"
 '
 
 pop_repo
-- 
2.10.0.230.g6f8d04b


  reply	other threads:[~2016-09-13  3:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13  3:22 [PATCH 0/16] fix config-reading in non-repos Jeff King
2016-09-13  3:23 ` Jeff King [this message]
2016-09-13 21:42   ` [PATCH 01/16] t1007: factor out repeated setup Stefan Beller
2016-09-13  3:23 ` [PATCH 02/16] hash-object: always try to set up the git repository Jeff King
2016-09-13  3:23 ` [PATCH 03/16] patch-id: use RUN_SETUP_GENTLY Jeff King
2016-09-13  3:23 ` [PATCH 04/16] diff: skip implicit no-index check when given --no-index Jeff King
2016-09-13  3:23 ` [PATCH 05/16] diff: handle --no-index prefixes consistently Jeff King
2016-09-13  3:23 ` [PATCH 06/16] diff: always try to set up the repository Jeff King
2016-09-13 22:00   ` Stefan Beller
2016-09-13 22:22     ` Jeff King
2016-09-13  3:23 ` [PATCH 07/16] pager: remove obsolete comment Jeff King
2016-09-13  3:23 ` [PATCH 08/16] pager: stop loading git_default_config() Jeff King
2016-09-13  3:23 ` [PATCH 09/16] pager: make pager_program a file-local static Jeff King
2016-09-13  3:23 ` [PATCH 10/16] pager: use callbacks instead of configset Jeff King
2016-09-13  3:23 ` [PATCH 11/16] pager: handle early config Jeff King
2016-09-13  3:24 ` [PATCH 12/16] t1302: use "git -C" Jeff King
2016-09-13  3:24 ` [PATCH 13/16] test-config: setup git directory Jeff King
2016-09-13  3:24 ` [PATCH 14/16] config: only read .git/config from configured repos Jeff King
2016-09-13  3:24 ` [PATCH 15/16] init: expand comments explaining config trickery Jeff King
2016-09-13  3:24 ` [PATCH 16/16] init: reset cached config when entering new repo Jeff King
2016-09-13 22:18   ` Stefan Beller
2016-09-14 10:55 ` [PATCH 0/16] fix config-reading in non-repos Dennis Kaarsemaker
2016-09-14 15:31   ` Jeff King

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=20160913032312.yheky2o25lmibvmb@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=dennis@kaarsemaker.net \
    --cc=git@vger.kernel.org \
    --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).