{"thread":{"id":"13915","subject":"[PATCH] test-lib: Allow to be used by contrib projects","startedAt":"2008-06-12T19:13:52Z","lastAt":"2008-06-12T19:13:53Z","messageCount":2,"participants":["Santi Béjar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"79613","messageId":"1213298033-6086-1-git-send-email-sbejar@gmail.com","threadId":"13915","inReplyTo":null,"subject":"[PATCH] test-lib: Allow to be used by contrib projects","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-12T19:13:52Z","receivedAt":"2008-06-12T19:13:52Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"The contrib project can have test scripts like the ones in git.git.\n\nThey only need a test-lib.sh and a Makefile like the following:\n\n[test-lib.sh]\n\nGIT_TEST_DIR=$(pwd)/../../../t\nPATH=$(pwd)/..:$PATH\n. ../../../t/test-lib.sh\n\n[end of test-lib.sh]\n\n[Makefile]\ninclude ../../../t/Makefile\n\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\n t/test-lib.sh |   15 ++++++++-------\n 1 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 7a8bd27..62976da 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -387,28 +387,29 @@ test_done () {\n \n # Test the binaries we have just built.  The tests are kept in\n # t/ subdirectory and are run in trash subdirectory.\n-PATH=$(pwd)/..:$PATH\n-GIT_EXEC_PATH=$(pwd)/..\n-GIT_TEMPLATE_DIR=$(pwd)/../templates/blt\n+[ -z \"$GIT_TEST_DIR\" ] && GIT_TEST_DIR=$(pwd)\n+PATH=$GIT_TEST_DIR/..:$PATH\n+GIT_EXEC_PATH=$GIT_TEST_DIR/..\n+GIT_TEMPLATE_DIR=$GIT_TEST_DIR/../templates/blt\n unset GIT_CONFIG\n unset GIT_CONFIG_LOCAL\n GIT_CONFIG_NOSYSTEM=1\n GIT_CONFIG_NOGLOBAL=1\n export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL\n \n-GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git\n+GITPERLLIB=$GIT_TEST_DIR/../perl/blib/lib:$GIT_TEST_DIR/../perl/blib/arch/auto/Git\n export GITPERLLIB\n-test -d ../templates/blt || {\n+test -d \"$GIT_TEMPLATE_DIR\" || {\n \terror \"You haven't built things yet, have you?\"\n }\n \n-if ! test -x ../test-chmtime; then\n+if ! test -x $GIT_TEST_DIR/../test-chmtime; then\n \techo >&2 'You need to build test-chmtime:'\n \techo >&2 'Run \"make test-chmtime\" in the source (toplevel) directory'\n \texit 1\n fi\n \n-. ../GIT-BUILD-OPTIONS\n+. $GIT_TEST_DIR/../GIT-BUILD-OPTIONS\n \n # Test repository\n test=\"trash directory\"\n-- \n1.5.5.3\n"},{"id":"79614","messageId":"1213298033-6086-2-git-send-email-sbejar@gmail.com","threadId":"13915","inReplyTo":"1213298033-6086-1-git-send-email-sbejar@gmail.com","subject":"[PATCH] contrib/what: \"git status\" for am/bisect/cherry-pick/merge/rebase/revert","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-06-12T19:13:53Z","receivedAt":"2008-06-12T19:13:53Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\nSigned-off-by: Santi Béjar <sbejar@gmail.com>\n---\nHi *,\n\n  for now, hoping the git-sequencer allows this, I've convert my git-what script\n  to a single script.\n\n  Also I've added some test that can be run thanks to my other path\n\n[PATCH] test-lib: Allow to be used by contrib projects\n\n But they can also be run if they are copied to the toplevel t/ directory. \n\n contrib/what/git-what                    |   86 ++++++++++++++++\n contrib/what/t/Makefile                  |    4 +\n contrib/what/t/t7800-what.sh             |  159 ++++++++++++++++++++++++++++++\n contrib/what/t/t7800/expect_am           |    3 +\n contrib/what/t/t7800/expect_bisect       |    3 +\n contrib/what/t/t7800/expect_cherry_pick  |    2 +\n contrib/what/t/t7800/expect_merge        |    2 +\n contrib/what/t/t7800/expect_merge_squash |    2 +\n contrib/what/t/t7800/expect_rebase       |    6 +\n contrib/what/t/t7800/expect_rebase_edit  |    9 ++\n contrib/what/t/t7800/expect_rebase_i     |    4 +\n contrib/what/t/t7800/expect_revert       |    2 +\n contrib/what/t/test-lib.sh               |    6 +\n 13 files changed, 288 insertions(+), 0 deletions(-)\n create mode 100755 contrib/what/git-what\n create mode 100644 contrib/what/t/Makefile\n create mode 100755 contrib/what/t/t7800-what.sh\n create mode 100644 contrib/what/t/t7800/expect_am\n create mode 100644 contrib/what/t/t7800/expect_bisect\n create mode 100644 contrib/what/t/t7800/expect_cherry_pick\n create mode 100644 contrib/what/t/t7800/expect_merge\n create mode 100644 contrib/what/t/t7800/expect_merge_squash\n create mode 100644 contrib/what/t/t7800/expect_rebase\n create mode 100644 contrib/what/t/t7800/expect_rebase_edit\n create mode 100644 contrib/what/t/t7800/expect_rebase_i\n create mode 100644 contrib/what/t/t7800/expect_revert\n create mode 100644 contrib/what/t/test-lib.sh\n\ndiff --git a/contrib/what/git-what b/contrib/what/git-what\nnew file mode 100755\nindex 0000000..5ea13b3\n--- /dev/null\n+++ b/contrib/what/git-what\n@@ -0,0 +1,86 @@\n+#!/bin/sh\n+\n+gitdir=\"$(git rev-parse --git-dir 2>/dev/null)\"\n+\n+test -z \"$gitdir\" && exit\n+\n+dotest=\"$gitdir/../.dotest\"\n+dotestint=\"$gitdir/.dotest-merge\"\n+\n+if [ -d \"$dotest\" ] ; then\n+    what=\"AM\"\n+    test -f \"$dotest/rebasing\" && what=\"REBASE\"\n+elif test -f \"$dotestint/interactive\" ; then\n+    what=\"REBASE-I\"\n+    test -f \"$dotestint/amend\" && what=\"REBASE-AMEND\"\n+elif test -f \"$gitdir/SQUASH_MSG\" ; then\n+    what=\"MERGE-SQUASH\"\n+elif test -f \"$gitdir/MERGE_HEAD\" ; then\n+    what=\"MERGE\"\n+elif test -f \"$gitdir/MERGE_MSG\" ; then\n+    what=\"PICK\"\n+elif test -f \"$gitdir/BISECT_LOG\" ; then\n+    what=\"BISECT\"\n+else\n+    exit 1\n+fi\n+\n+case $what in\n+    REBASE)\n+\tcmd=rebase\n+\tHELP=\"\n+When you have resolved this problem run \\\"git rebase --continue\\\".\n+If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n+To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n+\"\n+\t;;\n+    REBASE-AMEND)\n+\tcmd=\"rebase (edit)\"\n+\tHELP=\"\n+You can amend the commit now, with\n+\n+\tgit commit --amend\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\"\n+\t;;\n+    REBASE-AM)\n+\tcmd=rebase\n+\tHELP=\"  After resolving the conflicts,\n+mark the corrected paths with 'git add <paths>', and\n+run 'git rebase --continue'\"\n+\t;;\n+    REBASE-I)\n+\tcmd=\"rebase -i\"\n+\tHELP=\"  After resolving the conflicts,\n+mark the corrected paths with 'git add <paths>', and\n+run 'git rebase --continue'\"\n+\t;;\n+    AM)\n+\tcmd=\"\\\"git am\\\"\"\n+\tcmdline=\"git am\"\n+\tHELP=\"When you have resolved this problem run \\\"$cmdline --resolved\\\".\n+If you would prefer to skip this patch, instead run \\\"$cmdline --skip\\\".\"\n+\t;;\n+    MERGE)\n+\tcmd=merge\n+\tHELP=\"Fix conflicts and then commit the result.\"\n+\t;;\n+    MERGE-SQUASH)\n+\tcmd=\"merge --squash\"\n+\tHELP=\"Fix conflicts and then commit the result.\"\n+\t;;\n+    PICK)\n+\tcmd=\"prepared commit\"\n+\tHELP=\"Fix conflicts and then commit the result.\"\n+\t;;\n+    BISECT)\n+\tcmd=bisect\n+\tHELP='You need to give me at least one good and one bad revisions.\n+(You can use \"git bisect bad\" and \"git bisect good\" for that.)'\n+\t;;\n+esac\n+\n+echo \"You are in the middle of a $cmd:\"\n+echo \"$HELP\"\ndiff --git a/contrib/what/t/Makefile b/contrib/what/t/Makefile\nnew file mode 100644\nindex 0000000..790c81c\n--- /dev/null\n+++ b/contrib/what/t/Makefile\n@@ -0,0 +1,4 @@\n+# Run tests\n+#\n+\n+include ../../../t/Makefile\ndiff --git a/contrib/what/t/t7800-what.sh b/contrib/what/t/t7800-what.sh\nnew file mode 100755\nindex 0000000..93c5f60\n--- /dev/null\n+++ b/contrib/what/t/t7800-what.sh\n@@ -0,0 +1,159 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Santi Béjar, based on t4013 by Junio C Hamano\n+#\n+#\n+\n+test_description='What next?'\n+\n+. ./test-lib.sh\n+\n+LF='\n+'\n+\n+test_expect_success setup '\n+\tGIT_AUTHOR_DATE=\"2006-06-26 00:00:00 +0000\" &&\n+\tGIT_COMMITTER_DATE=\"2006-06-26 00:00:00 +0000\" &&\n+\texport GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&\n+\n+\techo 1 >file &&\n+\tgit add file &&\n+\tgit commit -a -m 1 &&\n+\tgit tag tag-1 &&\n+\tgit branch 1 &&\n+\n+\techo 1a >> file &&\n+\tgit commit -a -m 1a &&\n+\tgit tag tag-1a &&\n+\tgit branch 1a &&\n+\n+\techo 1a1 >> file &&\n+\tgit commit -a -m 1a1 &&\n+\tgit tag tag-1a1 &&\n+\tgit branch 1a1 &&\n+\n+        git reset --hard tag-1 &&\n+\techo 1b >> file &&\n+\tgit commit -a -m 1b &&\n+\tgit tag tag-1b &&\n+\tgit branch 1b\n+'\n+\n+test_output() {\n+    if test -f \"$1\"\n+    then\n+\ttest_cmp \"$1\" \"$2\" &&\n+\trm -f \"$2\"\n+    else\n+\t# this is to help developing new tests.\n+\tcp \"$2\" \"$1\"\n+\tfalse\n+    fi\n+}\n+\n+echo \"#!$SHELL_PATH\" >fake-editor.sh\n+cat >> fake-editor.sh <<\\EOF\n+case \"$1\" in\n+*/COMMIT_EDITMSG)\n+\ttest -z \"$FAKE_COMMIT_MESSAGE\" || echo \"$FAKE_COMMIT_MESSAGE\" > \"$1\"\n+\ttest -z \"$FAKE_COMMIT_AMEND\" || echo \"$FAKE_COMMIT_AMEND\" >> \"$1\"\n+\texit\n+\t;;\n+esac\n+test -z \"$EXPECT_COUNT\" ||\n+\ttest \"$EXPECT_COUNT\" = $(sed -e '/^#/d' -e '/^$/d' < \"$1\" | wc -l) ||\n+\texit\n+test -z \"$FAKE_LINES\" && exit\n+grep -v '^#' < \"$1\" > \"$1\".tmp\n+rm -f \"$1\"\n+cat \"$1\".tmp\n+action=pick\n+for line in $FAKE_LINES; do\n+\tcase $line in\n+\tsquash|edit)\n+\t\taction=\"$line\";;\n+\t*)\n+\t\techo sed -n \"${line}s/^pick/$action/p\"\n+\t\tsed -n \"${line}p\" < \"$1\".tmp\n+\t\tsed -n \"${line}s/^pick/$action/p\" < \"$1\".tmp >> \"$1\"\n+\t\taction=pick;;\n+\tesac\n+done\n+EOF\n+\n+test_set_editor \"$(pwd)/fake-editor.sh\"\n+chmod a+x fake-editor.sh\n+\n+test_expect_success \"what: nothing\" '\n+\t! git what\n+'\n+\n+test_expect_success \"what: bisect\" '\n+\tgit bisect start &&\n+\tgit what > output &&\n+\tgit bisect reset &&\n+\ttest_output ../t7800/expect_bisect output\n+'\n+\n+test_expect_success \"what: merge\" '\n+\tgit checkout master &&\n+\tgit reset --hard tag-1a &&\n+\t! git merge tag-1b &&\n+\tgit what > output &&\n+\ttest_output ../t7800/expect_merge output\n+'\n+\n+test_expect_success \"what: merge --squash\" '\n+\tgit reset --hard tag-1a &&\n+\t! git merge --squash tag-1b &&\n+\tgit what > output &&\n+\ttest_output ../t7800/expect_merge_squash output\n+'\n+\n+test_expect_success \"what: rebase\" '\n+\tgit reset --hard tag-1b &&\n+\t! git rebase tag-1a1 &&\n+\tgit what > output &&\n+\tgit rebase --abort &&\n+\ttest_output ../t7800/expect_rebase output\n+'\n+\n+test_expect_success 'what: rebase -i' '\n+\tgit reset --hard tag-1b &&\n+\t! git rebase -i tag-1a1 &&\n+\tgit what > output &&\n+\tgit rebase --abort &&\n+\ttest_output ../t7800/expect_rebase_i output\n+'\n+\n+test_expect_success 'what: rebase (amend)' '\n+\tgit reset --hard tag-1b &&\n+\tFAKE_LINES=\"edit 1\" git rebase -i HEAD^ &&\n+\tgit what > output &&\n+\tgit rebase --abort &&\n+\ttest_output ../t7800/expect_rebase_edit output\n+'\n+\n+test_expect_success \"what: cherry-pick\" '\n+\tgit reset --hard tag-1b &&\n+\t! git cherry-pick tag-1a &&\n+\tgit what > output &&\n+\ttest_output ../t7800/expect_cherry_pick output\n+'\n+\n+test_expect_success \"what: revert\" '\n+\tgit reset --hard tag-1a1 &&\n+\t! git revert tag-1a &&\n+\tgit what > output &&\n+\ttest_output ../t7800/expect_revert output\n+'\n+\n+test_expect_success \"what: am\" '\n+\tgit reset --hard tag-1b &&\n+\tgit format-patch --stdout tag-1..tag-1a1 > mbox &&\n+\t! git am mbox &&\n+\tgit what > output &&\n+\ttest_output ../t7800/expect_am output\n+'\n+\n+test_done\ndiff --git a/contrib/what/t/t7800/expect_am b/contrib/what/t/t7800/expect_am\nnew file mode 100644\nindex 0000000..618d93e\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_am\n@@ -0,0 +1,3 @@\n+You are in the middle of a \"git am\":\n+When you have resolved this problem run \"git am --resolved\".\n+If you would prefer to skip this patch, instead run \"git am --skip\".\ndiff --git a/contrib/what/t/t7800/expect_bisect b/contrib/what/t/t7800/expect_bisect\nnew file mode 100644\nindex 0000000..923396b\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_bisect\n@@ -0,0 +1,3 @@\n+You are in the middle of a bisect:\n+You need to give me at least one good and one bad revisions.\n+(You can use \"git bisect bad\" and \"git bisect good\" for that.)\ndiff --git a/contrib/what/t/t7800/expect_cherry_pick b/contrib/what/t/t7800/expect_cherry_pick\nnew file mode 100644\nindex 0000000..60e733e\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_cherry_pick\n@@ -0,0 +1,2 @@\n+You are in the middle of a prepared commit:\n+Fix conflicts and then commit the result.\ndiff --git a/contrib/what/t/t7800/expect_merge b/contrib/what/t/t7800/expect_merge\nnew file mode 100644\nindex 0000000..2c9b821\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_merge\n@@ -0,0 +1,2 @@\n+You are in the middle of a merge:\n+Fix conflicts and then commit the result.\ndiff --git a/contrib/what/t/t7800/expect_merge_squash b/contrib/what/t/t7800/expect_merge_squash\nnew file mode 100644\nindex 0000000..3cdd4fa\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_merge_squash\n@@ -0,0 +1,2 @@\n+You are in the middle of a merge --squash:\n+Fix conflicts and then commit the result.\ndiff --git a/contrib/what/t/t7800/expect_rebase b/contrib/what/t/t7800/expect_rebase\nnew file mode 100644\nindex 0000000..3975cc0\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_rebase\n@@ -0,0 +1,6 @@\n+You are in the middle of a rebase:\n+\n+When you have resolved this problem run \"git rebase --continue\".\n+If you would prefer to skip this patch, instead run \"git rebase --skip\".\n+To restore the original branch and stop rebasing run \"git rebase --abort\".\n+\ndiff --git a/contrib/what/t/t7800/expect_rebase_edit b/contrib/what/t/t7800/expect_rebase_edit\nnew file mode 100644\nindex 0000000..e4d76c2\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_rebase_edit\n@@ -0,0 +1,9 @@\n+You are in the middle of a rebase (edit):\n+\n+You can amend the commit now, with\n+\n+\tgit commit --amend\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\ndiff --git a/contrib/what/t/t7800/expect_rebase_i b/contrib/what/t/t7800/expect_rebase_i\nnew file mode 100644\nindex 0000000..e17f5a7\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_rebase_i\n@@ -0,0 +1,4 @@\n+You are in the middle of a rebase -i:\n+  After resolving the conflicts,\n+mark the corrected paths with 'git add <paths>', and\n+run 'git rebase --continue'\ndiff --git a/contrib/what/t/t7800/expect_revert b/contrib/what/t/t7800/expect_revert\nnew file mode 100644\nindex 0000000..60e733e\n--- /dev/null\n+++ b/contrib/what/t/t7800/expect_revert\n@@ -0,0 +1,2 @@\n+You are in the middle of a prepared commit:\n+Fix conflicts and then commit the result.\ndiff --git a/contrib/what/t/test-lib.sh b/contrib/what/t/test-lib.sh\nnew file mode 100644\nindex 0000000..1ce596a\n--- /dev/null\n+++ b/contrib/what/t/test-lib.sh\n@@ -0,0 +1,6 @@\n+#!/bin/sh\n+\n+GIT_TEST_DIR=$(pwd)/../../../t\n+PATH=$(pwd)/..:$PATH\n+. ../../../t/test-lib.sh\n+\n-- \n1.5.5.3\n"}]}