Skip to content

Commit

Permalink
Merge branch 'js/git-gdb'
Browse files Browse the repository at this point in the history
Allow easier debugging of a single "git" invocation in our test
scripts.

* js/git-gdb:
  test: facilitate debugging Git executables in tests with gdb
  • Loading branch information
Junio C Hamano committed Nov 3, 2015
2 parents acfeaf8 + 6a94088 commit 4b571eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions t/README
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ library for your script to use.
argument. This is primarily meant for use during the
development of a new test script.

- debug <git-command>

Run a git command inside a debugger. This is primarily meant for
use when debugging a failing test script.

- test_done

Your test script must have test_done at the end. Its purpose
Expand Down
8 changes: 8 additions & 0 deletions t/test-lib-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ test_pause () {
fi
}

# Wrap git in gdb. Adding this to a command can make it easier to
# understand what is going on in a failing test.
#
# Example: "debug git checkout master".
debug () {
GIT_TEST_GDB=1 "$@"
}

# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
#
# This will commit a file with the given contents and the given commit
Expand Down
8 changes: 7 additions & 1 deletion wrap-for-bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR

exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
if test -n "$GIT_TEST_GDB"
then
unset GIT_TEST_GDB
exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
else
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
fi

0 comments on commit 4b571eb

Please sign in to comment.