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

[PATCH 2/2] t3420-rebase-autostash: don't try to grep non-existing files

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 22, 2018, 18:13 UTC
Message-ID
<20180822181320.14055-2-szeder.dev@gmail.com>
In-Reply-To
<20180822181320.14055-1-szeder.dev@gmail.com>

Several tests in 't3420-rebase-autostash.sh' start various rebase processes that are expected to fail because of merge conflicts. These tests then run '! grep' to ensure that the autostash feature did its job, and the dirty contents of a file is gone. However, due to the test repo's history and the choice of upstream branch that file shouldn't exist in the conflicted state at all. Consequently, this 'grep' doesn't fail as expected, because it can't find the dirty content, but it fails because it can't open the file.

Tighten this check by using 'test_path_is_missing' instead, thereby avoiding unexpected errors from 'grep' as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t3420-rebase-autostash.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index e243700660..0c4eefec76 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -202,7 +202,7 @@ testrebase () {
 		echo dirty >>file3 &&
 		test_must_fail git rebase$type related-onto-branch &&
 		test_path_is_file $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		rm -rf $dotest &&
 		git reset --hard &&
 		git checkout feature-branch
@@ -216,7 +216,7 @@ testrebase () {
 		echo dirty >>file3 &&
 		test_must_fail git rebase$type related-onto-branch &&
 		test_path_is_file $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		echo "conflicting-plus-goodbye" >file2 &&
 		git add file2 &&
 		git rebase --continue &&
@@ -233,7 +233,7 @@ testrebase () {
 		echo dirty >>file3 &&
 		test_must_fail git rebase$type related-onto-branch &&
 		test_path_is_file $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		git rebase --skip &&
 		test_path_is_missing $dotest/autostash &&
 		grep dirty file3 &&
@@ -248,7 +248,7 @@ testrebase () {
 		echo dirty >>file3 &&
 		test_must_fail git rebase$type related-onto-branch &&
 		test_path_is_file $dotest/autostash &&
-		! grep dirty file3 &&
+		test_path_is_missing file3 &&
 		git rebase --abort &&
 		test_path_is_missing $dotest/autostash &&
 		grep dirty file3 &&
-- 
2.19.0.rc0.136.gd2dd172e64
Previous: SZEDER Gábor
Message 2 of 2 in “t3903-stash: don't try to grep non-existing file”
  1. 1/2 t3903-stash: don't try to grep non-existing fileSZEDER Gábor, Aug 22, 2018
  2. 2/2 t3420-rebase-autostash: don't try to grep non-existing filesSZEDER Gábor, Aug 22, 2018

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.