git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/5] t1500: be considerate to future potential tests

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 18, 2016, 20:15 UTC
Message-ID
<20160518201545.9113-2-sunshine@sunshineco.com>
In-Reply-To
<20160518201545.9113-1-sunshine@sunshineco.com>

The final batch of git-rev-parse tests work against a non-local object database named repo.git. This is done by renaming .git to repo.git and pointing GIT_DIR at it, but the name is never restored to .git at the end of the script, which can be problematic for tests added in the future. Be more friendly by instead making repo.git a copy of .git.

Furthermore, make it clear that tests in repo.git will be independent from the results of earlier tests done in .git by initializing repo.git earlier in the test sequence.

Likewise, bundle remaining preparation (such as directory creation) into a common setup test consistent with modern practice.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t1500-rev-parse.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/t/t1500-rev-parse.sh b/t/t1500-rev-parse.sh
index 48ee077..0194f54 100755
--- a/t/t1500-rev-parse.sh
+++ b/t/t1500-rev-parse.sh
@@ -37,6 +37,11 @@ test_rev_parse() {
 
 ROOT=$(pwd)
 
+test_expect_success 'setup' '
+	mkdir -p sub/dir work &&
+	cp -R .git repo.git
+'
+
 test_rev_parse toplevel false false true '' .git
 
 cd .git || exit 1
@@ -45,7 +50,6 @@ cd objects || exit 1
 test_rev_parse .git/objects/ false true false '' "$ROOT/.git"
 cd ../.. || exit 1
 
-mkdir -p sub/dir || exit 1
 cd sub/dir || exit 1
 test_rev_parse subdirectory false false true sub/dir/ "$ROOT/.git"
 cd ../.. || exit 1
@@ -56,7 +60,6 @@ test_rev_parse 'core.bare = true' true false false
 git config --unset core.bare
 test_rev_parse 'core.bare undefined' false false true
 
-mkdir work || exit 1
 cd work || exit 1
 GIT_DIR=../.git
 GIT_CONFIG="$(pwd)"/../.git/config
@@ -71,7 +74,6 @@ test_rev_parse 'GIT_DIR=../.git, core.bare = true' true false false ''
 git config --unset core.bare
 test_rev_parse 'GIT_DIR=../.git, core.bare undefined' false false true ''
 
-mv ../.git ../repo.git || exit 1
 GIT_DIR=../repo.git
 GIT_CONFIG="$(pwd)"/../repo.git/config
 
-- 
2.8.2.748.g927f425
Previous: Eric SunshineNext: Eric Sunshine
Message 2 of 6 in “modernize t1500”
  1. 0/5 modernize t1500Eric Sunshine, May 18, 2016
  2. 1/5 t1500: be considerate to future potential testsEric Sunshine, May 18, 2016
  3. 2/5 t1500: test_rev_parse: facilitate future test enhancementsEric Sunshine, May 18, 2016
  4. 3/5 t1500: avoid changing working directory outside of testsEric Sunshine, May 18, 2016
  5. 4/5 t1500: avoid setting configuration options outside of testsEric Sunshine, May 18, 2016
  6. 5/5 t1500: avoid setting environment variables outside of testsEric Sunshine, May 18, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.