test-lib: Allow to be used by contrib projects
PATCH 1/1 test-lib: Allow to be used by contrib projects
The contrib project can have test scripts like the ones in git.git.
They only need a test-lib.sh and a Makefile like the following:
[test-lib.sh]
GIT_TEST_DIR=$(pwd)/../../../t
PATH=$(pwd)/..:$PATH
. ../../../t/test-lib.sh
[end of test-lib.sh]
[Makefile]
include ../../../t/Makefile
--- t/test-lib.sh | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
t/test-lib.sh +8 -7
@@ -387,28 +387,29 @@ test_done () { # Test the binaries we have just built. The tests are kept in # t/ subdirectory and are run in trash subdirectory. -PATH=$(pwd)/..:$PATH -GIT_EXEC_PATH=$(pwd)/.. -GIT_TEMPLATE_DIR=$(pwd)/../templates/blt +[ -z "$GIT_TEST_DIR" ] && GIT_TEST_DIR=$(pwd) +PATH=$GIT_TEST_DIR/..:$PATH +GIT_EXEC_PATH=$GIT_TEST_DIR/.. +GIT_TEMPLATE_DIR=$GIT_TEST_DIR/../templates/blt unset GIT_CONFIG unset GIT_CONFIG_LOCAL GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG_NOGLOBAL=1 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL -GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git +GITPERLLIB=$GIT_TEST_DIR/../perl/blib/lib:$GIT_TEST_DIR/../perl/blib/arch/auto/Git export GITPERLLIB -test -d ../templates/blt || { +test -d "$GIT_TEMPLATE_DIR" || { error "You haven't built things yet, have you?" } -if ! test -x ../test-chmtime; then +if ! test -x $GIT_TEST_DIR/../test-chmtime; then echo >&2 'You need to build test-chmtime:' echo >&2 'Run "make test-chmtime" in the source (toplevel) directory' exit 1 fi -. ../GIT-BUILD-OPTIONS +. $GIT_TEST_DIR/../GIT-BUILD-OPTIONS # Test repository test="trash directory"
Signature · 1 line
1.5.5.3
PATCH 1/1 contrib/what: "git status" for am/bisect/cherry-pick/merge/rebase/revert
---
Hi *,
for now, hoping the git-sequencer allows this, I've convert my git-what script to a single script.
Also I've added some test that can be run thanks to my other path
[PATCH] test-lib: Allow to be used by contrib projects
But they can also be run if they are copied to the toplevel t/ directory.
contrib/what/git-what | 86 ++++++++++++++++ contrib/what/t/Makefile | 4 + contrib/what/t/t7800-what.sh | 159 ++++++++++++++++++++++++++++++ contrib/what/t/t7800/expect_am | 3 + contrib/what/t/t7800/expect_bisect | 3 + contrib/what/t/t7800/expect_cherry_pick | 2 + contrib/what/t/t7800/expect_merge | 2 + contrib/what/t/t7800/expect_merge_squash | 2 + contrib/what/t/t7800/expect_rebase | 6 + contrib/what/t/t7800/expect_rebase_edit | 9 ++ contrib/what/t/t7800/expect_rebase_i | 4 + contrib/what/t/t7800/expect_revert | 2 + contrib/what/t/test-lib.sh | 6 + 13 files changed, 288 insertions(+), 0 deletions(-) create mode 100755 contrib/what/git-what create mode 100644 contrib/what/t/Makefile create mode 100755 contrib/what/t/t7800-what.sh create mode 100644 contrib/what/t/t7800/expect_am create mode 100644 contrib/what/t/t7800/expect_bisect create mode 100644 contrib/what/t/t7800/expect_cherry_pick create mode 100644 contrib/what/t/t7800/expect_merge create mode 100644 contrib/what/t/t7800/expect_merge_squash create mode 100644 contrib/what/t/t7800/expect_rebase create mode 100644 contrib/what/t/t7800/expect_rebase_edit create mode 100644 contrib/what/t/t7800/expect_rebase_i create mode 100644 contrib/what/t/t7800/expect_revert create mode 100644 contrib/what/t/test-lib.sh
contrib/what/git-what new file +86 -0
@@ -0,0 +1,86 @@ +#!/bin/sh + +gitdir="$(git rev-parse --git-dir 2>/dev/null)" + +test -z "$gitdir" && exit + +dotest="$gitdir/../.dotest" +dotestint="$gitdir/.dotest-merge" + +if [ -d "$dotest" ] ; then + what="AM" + test -f "$dotest/rebasing" && what="REBASE" +elif test -f "$dotestint/interactive" ; then + what="REBASE-I" + test -f "$dotestint/amend" && what="REBASE-AMEND" +elif test -f "$gitdir/SQUASH_MSG" ; then + what="MERGE-SQUASH" +elif test -f "$gitdir/MERGE_HEAD" ; then + what="MERGE" +elif test -f "$gitdir/MERGE_MSG" ; then + what="PICK" +elif test -f "$gitdir/BISECT_LOG" ; then + what="BISECT" +else + exit 1 +fi + +case $what in + REBASE) + cmd=rebase + HELP=" +When you have resolved this problem run \"git rebase --continue\". +If you would prefer to skip this patch, instead run \"git rebase --skip\". +To restore the original branch and stop rebasing run \"git rebase --abort\". +" + ;; + REBASE-AMEND) + cmd="rebase (edit)" + HELP=" +You can amend the commit now, with + + git commit --amend + +Once you are satisfied with your changes, run + + git rebase --continue" + ;; + REBASE-AM) + cmd=rebase + HELP=" After resolving the conflicts, +mark the corrected paths with 'git add <paths>', and +run 'git rebase --continue'" + ;; + REBASE-I) + cmd="rebase -i" + HELP=" After resolving the conflicts, +mark the corrected paths with 'git add <paths>', and +run 'git rebase --continue'" + ;; + AM) + cmd="\"git am\"" + cmdline="git am" + HELP="When you have resolved this problem run \"$cmdline --resolved\". +If you would prefer to skip this patch, instead run \"$cmdline --skip\"." + ;; + MERGE) + cmd=merge + HELP="Fix conflicts and then commit the result." + ;; + MERGE-SQUASH) + cmd="merge --squash" + HELP="Fix conflicts and then commit the result." + ;; + PICK) + cmd="prepared commit" + HELP="Fix conflicts and then commit the result." + ;; + BISECT) + cmd=bisect + HELP='You need to give me at least one good and one bad revisions. +(You can use "git bisect bad" and "git bisect good" for that.)' + ;; +esac + +echo "You are in the middle of a $cmd:" +echo "$HELP"
contrib/what/t/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# Run tests +# + +include ../../../t/Makefile
contrib/what/t/t7800-what.sh new file +159 -0
159 lines not on this page · raw message
contrib/what/t/t7800/expect_am new file +3 -0
@@ -0,0 +1,3 @@ +You are in the middle of a "git am": +When you have resolved this problem run "git am --resolved". +If you would prefer to skip this patch, instead run "git am --skip".
contrib/what/t/t7800/expect_bisect new file +3 -0
@@ -0,0 +1,3 @@ +You are in the middle of a bisect: +You need to give me at least one good and one bad revisions. +(You can use "git bisect bad" and "git bisect good" for that.)
contrib/what/t/t7800/expect_cherry_pick new file +2 -0
@@ -0,0 +1,2 @@ +You are in the middle of a prepared commit: +Fix conflicts and then commit the result.
contrib/what/t/t7800/expect_merge new file +2 -0
@@ -0,0 +1,2 @@ +You are in the middle of a merge: +Fix conflicts and then commit the result.
contrib/what/t/t7800/expect_merge_squash new file +2 -0
@@ -0,0 +1,2 @@ +You are in the middle of a merge --squash: +Fix conflicts and then commit the result.
contrib/what/t/t7800/expect_rebase new file +6 -0
@@ -0,0 +1,6 @@ +You are in the middle of a rebase: + +When you have resolved this problem run "git rebase --continue". +If you would prefer to skip this patch, instead run "git rebase --skip". +To restore the original branch and stop rebasing run "git rebase --abort". +
contrib/what/t/t7800/expect_rebase_edit new file +9 -0
@@ -0,0 +1,9 @@ +You are in the middle of a rebase (edit): + +You can amend the commit now, with + + git commit --amend + +Once you are satisfied with your changes, run + + git rebase --continue
contrib/what/t/t7800/expect_rebase_i new file +4 -0
@@ -0,0 +1,4 @@ +You are in the middle of a rebase -i: + After resolving the conflicts, +mark the corrected paths with 'git add <paths>', and +run 'git rebase --continue'
contrib/what/t/t7800/expect_revert new file +2 -0
@@ -0,0 +1,2 @@ +You are in the middle of a prepared commit: +Fix conflicts and then commit the result.
contrib/what/t/test-lib.sh new file +6 -0
@@ -0,0 +1,6 @@ +#!/bin/sh + +GIT_TEST_DIR=$(pwd)/../../../t +PATH=$(pwd)/..:$PATH +. ../../../t/test-lib.sh +
Signature · 1 line
1.5.5.3