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

[PATCH 02/11] t2100: modernize style and unroll a loop of test cases

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 1, 2013, 09:34 UTC
Message-ID
<e0707cd8cb027e8fb7f17fd7ec1083cffc6e8fef.1370076477.git.j6t@kdbg.org>
In-Reply-To
<cover.1370076477.git.j6t@kdbg.org>
In particular, move all test preparations inside test_expect_success.

In a subsequent patch, we are going to move test case path3 out of the loop of test cases. Use this opportunity to linearize the tests.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 t/t2100-update-cache-badpath.sh | 81 ++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 34 deletions(-)
diff --git a/t/t2100-update-cache-badpath.sh b/t/t2100-update-cache-badpath.sh
index 2df3fdd..a3f9255 100755
--- a/t/t2100-update-cache-badpath.sh
+++ b/t/t2100-update-cache-badpath.sh
@@ -24,38 +24,51 @@ All of the attempts should fail.
 
 . ./test-lib.sh
 
-mkdir path2 path3
-date >path0
-if test_have_prereq SYMLINKS
-then
-	ln -s xyzzy path1
-else
-	date > path1
-fi
-date >path2/file2
-date >path3/file3
-
-test_expect_success \
-    'git update-index --add to add various paths.' \
-    'git update-index --add -- path0 path1 path2/file2 path3/file3'
-
-rm -fr path?
-
-mkdir path0 path1
-date >path2
-if test_have_prereq SYMLINKS
-then
-	ln -s frotz path3
-else
-	date > path3
-fi
-date >path0/file0
-date >path1/file1
-
-for p in path0/file0 path1/file1 path2 path3
-do
-	test_expect_success \
-	    "git update-index to add conflicting path $p should fail." \
-	    "test_must_fail git update-index --add -- $p"
-done
+test_expect_success 'git update-index --add to add various paths' '
+
+	mkdir path2 path3 &&
+	date >path0 &&
+	if test_have_prereq SYMLINKS
+	then
+		ln -s xyzzy path1
+	else
+		date >path1
+	fi &&
+	date >path2/file2 &&
+	date >path3/file3 &&
+	test_when_finished "rm -fr path0 path1 path2 path3" &&
+	git update-index --add -- path0 path1 path2/file2 path3/file3
+'
+
+test_expect_success 'git update-index to add conflicting path path0/file0 should fail' '
+
+	mkdir path0 &&
+	date >path0/file0 &&
+	test_must_fail git update-index --add -- path0/file0
+'
+
+test_expect_success 'git update-index to add conflicting path path1/file1 should fail' '
+
+	mkdir path1 &&
+	date >path1/file1 &&
+	test_must_fail git update-index --add -- path1/file1
+'
+
+test_expect_success 'git update-index to add conflicting file path2 should fail' '
+
+	date >path2 &&
+	test_must_fail git update-index --add -- path2
+'
+
+test_expect_success 'git update-index to add conflicting symlink path3 should fail' '
+
+	if test_have_prereq SYMLINKS
+	then
+		ln -s xyzzy path3
+	else
+		date >path3
+	fi &&
+	test_must_fail git update-index --add -- path3
+'
+
 test_done
-- 
1.8.3.rc1.32.g8b61cbb
Previous: Johannes SixtNext: Johannes Sixt
Message 3 of 35 in “Increase test coverage on Windows by removing SYMLINKS from many tests”
  1. 00/11 Increase test coverage on Windows by removing SYMLINKS from many testsJohannes Sixt, Jun 1, 2013
  2. 01/11 test-chmtime: Fix exit code on WindowsJohannes Sixt, Jun 1, 2013
  3. 02/11 t2100: modernize style and unroll a loop of test casesJohannes Sixt, Jun 1, 2013
  4. 03/11 t3010: modernize styleJohannes Sixt, Jun 1, 2013
  5. 04/11 tests: introduce test_ln_s and test_ln_s_addJohannes Sixt, Jun 1, 2013
  6. Ramkumar RamachandraJun 1, 2013
  7. Johannes SixtJun 1, 2013
  8. Ramkumar RamachandraJun 1, 2013
  9. 05/11 tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)Johannes Sixt, Jun 1, 2013
  10. Junio C HamanoJun 4, 2013
  11. Johannes SixtJun 5, 2013
  12. Junio C HamanoJun 4, 2013
  13. Johannes SixtJun 5, 2013
  14. 06/11 t0000: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  15. 07/11 t2100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  16. Junio C HamanoJun 4, 2013
  17. Johannes SixtJun 5, 2013
  18. 08/11 t3030: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  19. 09/11 t3100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  20. 10/11 t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  21. Junio C HamanoJun 2, 2013
  22. 11/11 t6035: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 1, 2013
  23. 00/10 Increase test coverage on Windows by removing SYMLINKS from many testsJohannes Sixt, Jun 7, 2013
  24. Junio C HamanoJun 7, 2013
  25. 01/10 test-chmtime: Fix exit code on WindowsJohannes Sixt, Jun 7, 2013
  26. Erik Faye-LundNov 20, 2013
  27. 02/10 t3010: modernize styleJohannes Sixt, Jun 7, 2013
  28. 03/10 tests: introduce test_ln_s_addJohannes Sixt, Jun 7, 2013
  29. 04/10 tests: use test_ln_s_add to remove SYMLINKS prerequisite (trivial cases)Johannes Sixt, Jun 7, 2013
  30. 05/10 t0000: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  31. 06/10 t3030: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  32. 07/10 t3100: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  33. 08/10 t3509, t4023, t4114: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  34. 09/10 t6035: use test_ln_s_add to remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013
  35. 10/10 t4011: remove SYMLINKS prerequisiteJohannes Sixt, Jun 7, 2013

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.