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

[PATCH] t5404: relax overzealous test

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 6, 2018, 19:31 UTC
Message-ID
<958ee6f006aba0c67c8e064d31206e3e68a1cc49.1523043053.git.johannes.schindelin@gmx.de>

In 0b294c0abf0 (make deleting a missing ref more quiet, 2008-07-08), we added a test to verify that deleting an already-deleted ref does not show an error.

Our test simply looks for the substring 'error' in the output of the `git push`, which might look innocuous on the face of it.

Suppose, however, that you are a big fan of whales. Or even better: your IT administrator has a whale of a time picking cute user names, e.g. referring to you (due to your like of India Pale Ales) as "one of the cuter rorquals" (see https://en.wikipedia.org/wiki/Rorqual to learn a thing or two about rorquals) and hence your home directory becomes /home/cuterrorqual. If you now run t5404, it fails! Why? Because the test calls `git push origin :b3` which outputs:

    To /home/cuterrorqual/git/t/trash directory.t5404-tracking-branches/.
     - [deleted]         b3

Note how there is no error displayed in that output? But of course "error" is a substring of "cuterrorqual". And so that `grep error output` finds something.

This bug was not, actually, caught having "error" as a substring of the user name but while working in a worktree called "colorize-push-errors", whose name was part of that output, too, suggesting that not even testing for the *word* `error` via `git grep -w error output` would fix the underlying issue.

This patch chooses instead to look for the prefix "error:" at the beginning of the line, so that there can be no ambiguity that any catch was indeed a message generated by Git's `error_builtin()` function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Published-As: https://github.com/dscho/git/releases/tag/fix-t5404-error-v1
Fetch-It-Via: git fetch https://github.com/dscho/git fix-t5404-error-v1
 t/t5404-tracking-branches.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/t5404-tracking-branches.sh b/t/t5404-tracking-branches.sh
index 2b8c0bac7db..2762f420bc2 100755
--- a/t/t5404-tracking-branches.sh
+++ b/t/t5404-tracking-branches.sh
@@ -56,7 +56,7 @@ test_expect_success 'deleted branches have their tracking branches removed' '
 test_expect_success 'already deleted tracking branches ignored' '
 	git branch -d -r origin/b3 &&
 	git push origin :b3 >output 2>&1 &&
-	! grep error output
+	! grep "^error: " output
 '
 
 test_done

base-commit: 468165c1d8a442994a825f3684528361727cd8c0
-- 
2.17.0.windows.1.4.g7e4058d72e3
Next: Jeff King
Message 1 of 7 in “t5404: relax overzealous test”
  1. t5404: relax overzealous testJohannes Schindelin, Apr 6, 2018
  2. Jeff KingApr 6, 2018
  3. Johannes SchindelinApr 6, 2018
  4. Jeff KingApr 6, 2018
  5. Ævar Arnfjörð BjarmasonApr 6, 2018
  6. Junio C HamanoApr 9, 2018
  7. Johannes SchindelinApr 9, 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.