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

[PATCH] t3200: don't grep for `strerror()` string

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Jul 18, 2020, 09:48 UTC
Message-ID
<20200718094840.31269-1-martin.agren@gmail.com>
In-Reply-To
<00d001d65c80$3519c960$9f4d5c20$@nexbridge.com>

In 6b7093064a ("t3200: test for specific errors", 2020-06-15), we learned to grep stderr to ensure that the failing `git branch` invocations fail for the right reason. In two of these tests, we grep for "File exists", expecting the string to show up there since config.c calls `error_errno()`, which ends up including `strerror(errno)` in the error message.

But as we saw in 4605a73073 ("t1091: don't grep for `strerror()` string", 2020-03-08), there exists at least one implementation where `strerror()` yields a slightly different string than the one we're grepping for. In particular, these tests fail on the NonStop platform.

Similar to 4605a73073, grep for the beginning of the string instead to avoid relying on `strerror()` behavior.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 Hi Randall,
 Does this fix the test for you?
 Martin
 t/t3200-branch.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index b6aa04bbec..4c0734157b 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -870,7 +870,7 @@ test_expect_success '--set-upstream-to fails on locked config' '
 	>.git/config.lock &&
 	git branch locked &&
 	test_must_fail git branch --set-upstream-to locked 2>err &&
-	test_i18ngrep "could not lock config file .git/config: File exists" err
+	test_i18ngrep "could not lock config file .git/config" err
 '
 
 test_expect_success 'use --set-upstream-to modify HEAD' '
@@ -901,7 +901,7 @@ test_expect_success '--unset-upstream should fail if config is locked' '
 	git branch --set-upstream-to locked &&
 	>.git/config.lock &&
 	test_must_fail git branch --unset-upstream 2>err &&
-	test_i18ngrep "could not lock config file .git/config: File exists" err
+	test_i18ngrep "could not lock config file .git/config" err
 '
 
 test_expect_success 'test --unset-upstream on HEAD' '
-- 
2.28.0.rc0
Previous: Randall S. BeckerNext: Junio C Hamano
Message 3 of 7 in “[ANNOUNCE] Git v2.28.0-rc1”
  1. Junio C HamanoJul 17, 2020
  2. Randall S. BeckerJul 17, 2020
  3. t3200: don't grep for `strerror()` stringMartin Ågren, Jul 18, 2020
  4. Junio C HamanoJul 18, 2020
  5. Martin ÅgrenJul 18, 2020
  6. Randall S. BeckerJul 19, 2020
  7. Randall S. BeckerJul 19, 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.