{"thread":{"id":"47919","subject":"[PATCH v2 2/2] t5536: simplify checking of messages output to stderr","startedAt":"2018-02-24T01:22:26Z","lastAt":"2018-02-24T01:22:26Z","messageCount":1,"participants":["Ramsay Jones"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"340146","messageId":"550fb3f4-8d25-c5c4-0ecd-3a4e61ea13f4@ramsayjones.plus.com","threadId":"47919","inReplyTo":null,"subject":"[PATCH v2 2/2] t5536: simplify checking of messages output to stderr","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2018-02-24T01:22:19Z","receivedAt":"2018-02-24T01:22:26Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"From: SZEDER Gábor <szeder.dev@gmail.com>\n\nCommit 2071e05ed2 (\"t5536: new test of refspec conflicts when\nfetching\", 2013-10-30), introduced the verify_stderr() function\nwhich was used to verify that certain fatal/warning messages were\nissued by a given git command. In addition, verify_stderr() would\nfilter a specific \"fatal: The remote end hung up unexpectedly\"\nmessage, which may, or may not, be present (depending on the\nrelative timing of the git-fetch and git-upload-pack processes).\n\nThe verify_stderr() function has seen several modifications, which\nhas introduced a couple of minor problems. For example, commit\n1edbaac3bb (\"tests: use test_i18n* functions to suppress false\npositives\", 2016-06-17) introduced an inappropriate test_i18ngrep\ncall and commit f096e6e826 (\"fetch: improve the error messages\nemitted for conflicting refspecs\", 2013-10-30) included an\nineffective invocation of sort at the end of a grep pipeline.\n\nInstead of fixing these minor problems in verify_stderr(), we take\nthe simpler approach of directly searching the error file, using\ntest_i18ngrep, for the specific message(s) we expect. (The only\nminor downside is that we would not notice any new messages).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n t/t5536-fetch-conflicts.sh | 22 ++++------------------\n 1 file changed, 4 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t5536-fetch-conflicts.sh b/t/t5536-fetch-conflicts.sh\nindex 644736b8a..91f28c2f7 100755\n--- a/t/t5536-fetch-conflicts.sh\n+++ b/t/t5536-fetch-conflicts.sh\n@@ -18,14 +18,6 @@ setup_repository () {\n \t)\n }\n \n-verify_stderr () {\n-\tcat >expected &&\n-\t# We're not interested in the error\n-\t# \"fatal: The remote end hung up unexpectedly\":\n-\ttest_i18ngrep -E '^(fatal|warning):' error | grep -v 'hung up' >actual | sort &&\n-\ttest_i18ncmp expected actual\n-}\n-\n test_expect_success 'setup' '\n \tgit commit --allow-empty -m \"Initial\" &&\n \tgit branch branch1 &&\n@@ -48,9 +40,7 @@ test_expect_success 'fetch conflict: config vs. config' '\n \t\t\"+refs/heads/branch2:refs/remotes/origin/branch1\" && (\n \t\tcd ccc &&\n \t\ttest_must_fail git fetch origin 2>error &&\n-\t\tverify_stderr <<-\\EOF\n-\t\tfatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\n-\t\tEOF\n+\t\ttest_i18ngrep \"fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\" error\n \t)\n '\n \n@@ -77,9 +67,7 @@ test_expect_success 'fetch conflict: arg vs. arg' '\n \t\ttest_must_fail git fetch origin \\\n \t\t\trefs/heads/*:refs/remotes/origin/* \\\n \t\t\trefs/heads/branch2:refs/remotes/origin/branch1 2>error &&\n-\t\tverify_stderr <<-\\EOF\n-\t\tfatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\n-\t\tEOF\n+\t\ttest_i18ngrep \"fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\" error\n \t)\n '\n \n@@ -90,10 +78,8 @@ test_expect_success 'fetch conflict: criss-cross args' '\n \t\tgit fetch origin \\\n \t\t\trefs/heads/branch1:refs/remotes/origin/branch2 \\\n \t\t\trefs/heads/branch2:refs/remotes/origin/branch1 2>error &&\n-\t\tverify_stderr <<-\\EOF\n-\t\twarning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2\n-\t\twarning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1\n-\t\tEOF\n+\t\ttest_i18ngrep \"warning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2\" error &&\n+\t\ttest_i18ngrep \"warning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1\" error\n \t)\n '\n \n-- \n2.16.0\n"}]}