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

[PATCH v2 1/4] t6038: make tests fail for the right reason

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 3, 2020, 18:41 UTC
Message-ID
<21033c4c1455bb1e0bd996a5861cc9414912768f.1596480080.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.825.v2.git.git.1596480080.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

t6038 had a pair of tests that were expected to fail, but weren't failing for the expected reason. Both were meant to do a merge that could be done cleanly after renormalization, but were supposed to fail for lack of renormalization. Unfortunately, both tests had staged changes, and checkout -m would abort due to the presence of those staged changes before even attempting a merge.

Fix this first issue by utilizing git-restore instead of git-checkout, so that the index is left alone and just the working directory gets the changes we want.

However, there is a second issue with these tests. Technically, they just wanted to verify that after renormalization, no conflicts would be present. This could have been checked for by grepping for a lack of conflict markers, but the test instead tried to compare the working directory files to an expected result. Unfortunately, the setting of "text=auto" without setting core.eol to any value meant that the content of the file (in particular, the line endings) would be platform-dependent and the tests could only pass on some platforms. Replace the existing comparison with a call to 'git diff --no-index --ignore-cr-at-eol' to verify that the contents, other than possible carriage returns in the file, match the expected results and in particular that the file has no conflicts from the checkout -m operation.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6038-merge-text-auto.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh
index 5e8d5fa50c..27cea15533 100755
--- a/t/t6038-merge-text-auto.sh
+++ b/t/t6038-merge-text-auto.sh
@@ -168,9 +168,9 @@ test_expect_failure 'checkout -m after setting text=auto' '
 	git rm -fr . &&
 	rm -f .gitattributes &&
 	git reset --hard initial &&
-	git checkout a -- . &&
+	git restore --source=a -- . &&
 	git checkout -m b &&
-	compare_files expected file
+	git diff --no-index --ignore-cr-at-eol expected file
 '
 
 test_expect_failure 'checkout -m addition of text=auto' '
@@ -183,9 +183,9 @@ test_expect_failure 'checkout -m addition of text=auto' '
 	git rm -fr . &&
 	rm -f .gitattributes file &&
 	git reset --hard initial &&
-	git checkout b -- . &&
+	git restore --source=b -- . &&
 	git checkout -m a &&
-	compare_files expected file
+	git diff --no-index --ignore-cr-at-eol expected file
 '
 
 test_expect_failure 'cherry-pick patch from after text=auto was added' '
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 15 of 18 in “Attr fixes”
  1. 0/4 Attr fixesElijah Newren via GitGitGadget, Aug 2, 2020
  2. 1/4 t6038: make tests fail for the right reasonElijah Newren via GitGitGadget, Aug 2, 2020
  3. Junio C HamanoAug 2, 2020
  4. Eric SunshineAug 2, 2020
  5. Elijah NewrenAug 3, 2020
  6. 3/4 merge: make merge.renormalize work for all uses of merge machineryElijah Newren via GitGitGadget, Aug 2, 2020
  7. Junio C HamanoAug 2, 2020
  8. Elijah NewrenAug 3, 2020
  9. 4/4 checkout: support renormalization with checkout -m <paths>Elijah Newren via GitGitGadget, Aug 2, 2020
  10. 2/4 t6038: fix test with obviously incorrect expectationsElijah Newren via GitGitGadget, Aug 2, 2020
  11. Junio C HamanoAug 2, 2020
  12. Elijah NewrenAug 3, 2020
  13. Junio C HamanoAug 3, 2020
  14. 0/4 Attr fixesElijah Newren via GitGitGadget, Aug 3, 2020
  15. 1/4 t6038: make tests fail for the right reasonElijah Newren via GitGitGadget, Aug 3, 2020
  16. 4/4 checkout: support renormalization with checkout -m <paths>Elijah Newren via GitGitGadget, Aug 3, 2020
  17. 2/4 t6038: remove problematic testElijah Newren via GitGitGadget, Aug 3, 2020
  18. 3/4 merge: make merge.renormalize work for all uses of merge machineryElijah Newren via GitGitGadget, Aug 3, 2020

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.