{"thread":{"id":"949","subject":"[PATCH 1/3] Add test cases for git-commit-script.","startedAt":"2005-06-15T14:38:08Z","lastAt":"2005-06-15T14:38:08Z","messageCount":1,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"4973","messageId":"20050615143808.27230.qmail@blackcubes.dyndns.org","threadId":"949","inReplyTo":null,"subject":"[PATCH 1/3] Add test cases for git-commit-script.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2005-06-15T14:38:08Z","receivedAt":"2005-06-15T14:38:08Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"\nAdds some tests to show that git-commit-script behaves properly under a number\nof different conditions.\n\nThe git-commit-script (f88a51a43ce2a3660fa82c13e502df429678d168) at Linus' HEAD\npasses these tests.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n\n t/t1200-commit-script.sh |  153 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 153 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t1200-commit-script.sh b/t/t1200-commit-script.sh\nnew file mode 100644\n--- /dev/null\n+++ b/t/t1200-commit-script.sh\n@@ -0,0 +1,153 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2005 Rene Scharfe\n+# Copyright (C) 2005 Jon Seymour [ adapted to git-commit-script ]\n+#\n+\n+test_description='git-commit-script\n+\n+This test checks that git-commit-script works as expected.\n+'\n+\n+. ./test-lib.sh\n+\n+one_line()\n+{\n+echo \"this is a commit test\"\n+}\n+\n+expected_commit ()\n+{\n+\ttree=$1\n+\tshift 1\n+cat <<EOF\n+tree $tree\n+EOF\n+\n+\tfor p in $*\n+\tdo\n+cat <<EOF\n+parent $p\n+EOF\n+\tdone\n+\n+cat <<EOF\n+author Author Name <author@email> 1117148400 +0000\n+committer Committer Name <committer@email> 1117150200 +0000\n+\n+$(one_line)\n+EOF\n+}\n+\n+cat >add_one_line_editor <<EOF\n+#!/bin/sh\n+file=\\$1\n+echo \"$(one_line)\" >> \\$file\n+EOF\n+\n+cat >do_nothing_editor <<EOF\n+#!/bin/sh\n+:\n+EOF\n+\n+cat >delete_sentinel_editor <<EOF\n+#!/bin/sh\n+file=\\$1\n+mv \\$file \\$file.\\$\\$\n+sed \"/^#SENTINEL/d\" < \\$file.\\$\\$ >\\$file\n+EOF\n+\n+chmod u+x add_one_line_editor\n+chmod u+x do_nothing_editor\n+chmod u+x delete_sentinel_editor\n+\n+: > foo\n+: > bar\n+\n+run_with_vars()\n+{\n+     GIT_AUTHOR_NAME=\"Author Name\" \\\n+     GIT_AUTHOR_EMAIL=\"author@email\" \\\n+     GIT_AUTHOR_DATE=\"2005-05-26 23:00\" \\\n+     GIT_COMMITTER_NAME=\"Committer Name\" \\\n+     GIT_COMMITTER_EMAIL=\"committer@email\" \\\n+     GIT_COMMITTER_DATE=\"2005-05-26 23:30\" \\\n+     TZ= \"$@\" 2>/dev/null\n+}\n+\n+test_phase1()\n+{\n+     condition=$1\n+     editor=$2\n+\n+     test_expect_success \\\n+     \"$condition - test preparation: add a file\" \\\n+     'git-update-cache --add foo && git-write-tree > treeid'\n+\n+     test_expect_failure \\\n+     \"$condition - Do not edit the commit message\" \\\n+     \"EDITOR=$editor run_with_vars git-commit-script\"\n+\n+     test_expect_failure \\\n+     \"$condition - No HEAD created when commit fails\" \\\n+     '[ -f .git/HEAD ]'\n+}\n+\n+test_phase2()\n+{\n+    condition=$1\n+    editor=$2\n+    test_expect_success \\\n+    \"$condition - Single line message works\" \\\n+    \"EDITOR=$editor run_with_vars git-commit-script\"\n+\n+    test_expect_success \"$condition - HEAD created\" '[ -f .git/HEAD ]'\n+\n+    test_expect_success \\\n+    \"$condition - read commit 1\" \\\n+    'git-cat-file commit HEAD >commit'\n+\n+    test_expect_success \\\n+    \"$condition - compare commit\" \\\n+    'expected_commit $(cat treeid) > expected && diff expected commit'\n+\n+    head=$(cat .git/HEAD)\n+    test_expect_success \\\n+    \"$condition - create a merge head\" \\\n+    'merge_head=$(git-commit-tree $(cat treeid) -p HEAD < /dev/null)'\n+\n+    echo $merge_head > .git/MERGE_HEAD\n+\n+    test_expect_success \\\n+    \"$condition - test preparation: write tree containing\" \\\n+    'git-update-cache --add bar && git-write-tree > treeid.bar'\n+\n+}\n+\n+test_phase3()\n+{\n+    condition=$1\n+    editor=$2\n+\n+    test_expect_success \\\n+    \"$condition - write a tree with one merge head\" \\\n+    \"EDITOR=$editor run_with_vars git-commit-script\"\n+    \n+    test_expect_success \"$condition - MERGE_HEAD removed\" '[ -f .git/HEAD ]'\n+    test_expect_success \"$condition - MERGE_HEAD removed by successful commit\" '! [ -f .git/MERGE_HEAD ]'\n+\n+    test_expect_success \\\n+    \"$condition - read commit 2\" \\\n+    'git-cat-file commit HEAD >commit'\n+\n+    test_expect_success \\\n+    \"$condition - compare commit 2\" \\\n+    \"expected_commit $(cat treeid.bar) ${head} ${merge_head} > expected && diff expected commit\"\n+\n+}\n+\n+test_phase1 \"simulated user\" ./do_nothing_editor\n+test_phase2 \"simulated user\" ./add_one_line_editor\n+test_phase3 \"simulated used\" ./add_one_line_editor\n+\n+test_done\n------------\n"}]}