{"thread":{"id":"35151","subject":"[PATCH] t4254: modernize tests","startedAt":"2013-10-16T12:27:16Z","lastAt":"2013-10-16T12:27:16Z","messageCount":1,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"229070","messageId":"1381926436-12493-1-git-send-email-szeder@ira.uka.de","threadId":"35151","inReplyTo":null,"subject":"[PATCH] t4254: modernize tests","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-10-16T12:27:16Z","receivedAt":"2013-10-16T12:27:16Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"- Don't start tests with 'test $? = 0' ;)\n- Move writing the bogus patch and the expected output into the\n  appropriate test_expect_success blocks.\n- Use the test_must_fail helper instead of manually checking for\n  non-zero exit code.\n- Use the debug-friendly test_path_is_file helper instead of 'test -f'.\n- No space after '>'.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\nIs the exact match of 'git am's exit code important?  I think it doesn't\nmatter as long as it fails, hence test_must_fail instead of\ntest_expect_code 1.\n\n t/t4254-am-corrupt.sh | 36 +++++++++++++++---------------------\n 1 file changed, 15 insertions(+), 21 deletions(-)\n\ndiff --git a/t/t4254-am-corrupt.sh b/t/t4254-am-corrupt.sh\nindex b7da95fac5..85716dd6ec 100755\n--- a/t/t4254-am-corrupt.sh\n+++ b/t/t4254-am-corrupt.sh\n@@ -3,20 +3,19 @@\n test_description='git am with corrupt input'\n . ./test-lib.sh\n \n-# Note the missing \"+++\" line:\n-cat > bad-patch.diff <<'EOF'\n-From: A U Thor <au.thor@example.com>\n-diff --git a/f b/f\n-index 7898192..6178079 100644\n---- a/f\n-@@ -1 +1 @@\n--a\n-+b\n-EOF\n-\n test_expect_success setup '\n-\ttest $? = 0 &&\n-\techo a > f &&\n+\t# Note the missing \"+++\" line:\n+\tcat >bad-patch.diff <<-\\EOF &&\n+\tFrom: A U Thor <au.thor@example.com>\n+\tdiff --git a/f b/f\n+\tindex 7898192..6178079 100644\n+\t--- a/f\n+\t@@ -1 +1 @@\n+\t-a\n+\t+b\n+\tEOF\n+\n+\techo a >f &&\n \tgit add f &&\n \ttest_tick &&\n \tgit commit -m initial\n@@ -26,17 +25,12 @@ test_expect_success setup '\n #   fatal: unable to write file '(null)' mode 100644: Bad address\n # Also, it had the unwanted side-effect of deleting f.\n test_expect_success 'try to apply corrupted patch' '\n-\tgit am bad-patch.diff 2> actual\n-\ttest $? = 1\n+\ttest_must_fail git am bad-patch.diff 2>actual\n '\n \n-cat > expected <<EOF\n-fatal: git diff header lacks filename information (line 4)\n-EOF\n-\n test_expect_success 'compare diagnostic; ensure file is still here' '\n-\ttest $? = 0 &&\n-\ttest -f f &&\n+\techo \"fatal: git diff header lacks filename information (line 4)\" >expected &&\n+\ttest_path_is_file f &&\n \ttest_cmp expected actual\n '\n \n-- \n1.8.4.1.495.gd8d272e\n"}]}