In this guide, we want to set a breakpoint when debugging test case
"batch-command remote-object-info http://"
in ./t1017-cat-file-remote-object-info.sh
.
-
Put pause and print line in the test case.
We want the test pause so that we can run debugger on it and break at a certain break point. For example, I want to test the case
"batch-command remote-object-info http://"
in./t1017-cat-file-remote-object-info.sh
here is what I will do-
run
./t1017-cat-file-remote-object-info.sh -vd
,-v
is verbose, since we are printing;-d
is the debug flag. See https://gitlab.com/gitlab-org/git/-/blob/master/t/README?ref_type=heads -
I put this in the
"batch-command remote-object-info http://"
in the test case, just right before thegit
command is calledtest_write_lines "$(pwd)" "file://${server_path}" $hello_oid $tree_oid $commit_oid $tag_oid && test_pause &&
# This is the snippet of the test case code # ... echo "$tag_oid missing" >>expect && test_write_lines "$(pwd)" "file://${server_path}" $hello_oid $tree_oid $commit_oid $tag_oid && test_pause && git cat-file --batch-command="%(objectname) %(objectsize)" >actual <<-EOF && remote-object-info "$HTTPD_URL/smart/http_parent" $hello_oid remote-object-info "$HTTPD_URL/smart/http_parent" $tree_oid # ...
-
-
Set a breakpoint in IDE (JetBrain CLion)
-
Create a debug profile, profile’s config may dependent on which test case we want to debug on. Here is an example
-
Executable
(required) is the git binary in you git repo -
Program arguments
(required) iscat-file --batch-command="%(objectname) %(objectsize)"
-
Working directory
(optional) is where is our working dir when running the git command - Environment variables:
-
GIT_EXEC_PATH
(required) is Git looks for its sub-programs (likegit-commit
,git-diff
, and others), we are debugging our owngit-cat-file
so we need to set this
-
-
-
Set break point and run the debug profile
-
Because we are testing
cat-file
, so will need input from console
-