Skip to content

Commit 26ad216

Browse files
committed
Merge branch 'jl/test-pause'
* jl/test-pause: test-lib: add the test_pause convenience function
2 parents bff64a9 + c4d2539 commit 26ad216

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

t/README

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,19 @@ library for your script to use.
548548
...
549549
'
550550

551+
- test_pause
552+
553+
This command is useful for writing and debugging tests and must be
554+
removed before submitting. It halts the execution of the test and
555+
spawns a shell in the trash directory. Exit the shell to continue
556+
the test. Example:
557+
558+
test_expect_success 'test' '
559+
git do-something >actual &&
560+
test_pause &&
561+
test_cmp expected actual
562+
'
563+
551564
Prerequisites
552565
-------------
553566

t/test-lib.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,19 @@ test_tick () {
329329
export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
330330
}
331331

332+
# Stop execution and start a shell. This is useful for debugging tests and
333+
# only makes sense together with "-v".
334+
#
335+
# Be sure to remove all invocations of this command before submitting.
336+
337+
test_pause () {
338+
if test "$verbose" = t; then
339+
"$SHELL_PATH" <&6 >&3 2>&4
340+
else
341+
error >&5 "test_pause requires --verbose"
342+
fi
343+
}
344+
332345
# Call test_commit with the arguments "<message> [<file> [<contents>]]"
333346
#
334347
# This will commit a file with the given contents and the given commit

0 commit comments

Comments
 (0)