@@ -137,33 +137,110 @@ test_tick () {
137
137
# Stop execution and start a shell. This is useful for debugging tests.
138
138
#
139
139
# Be sure to remove all invocations of this command before submitting.
140
+ # WARNING: the shell invoked by this helper does not have the same environment
141
+ # as the one running the tests (shell variables and functions are not
142
+ # available, and the options below further modify the environment). As such,
143
+ # commands copied from a test script might behave differently than when
144
+ # running the test.
145
+ #
146
+ # Usage: test_pause [options]
147
+ # -t
148
+ # Use your original TERM instead of test-lib.sh's "dumb".
149
+ # This usually restores color output in the invoked shell.
150
+ # -s
151
+ # Invoke $SHELL instead of $TEST_SHELL_PATH.
152
+ # -h
153
+ # Use your original HOME instead of test-lib.sh's "$TRASH_DIRECTORY".
154
+ # This allows you to use your regular shell environment and Git aliases.
155
+ # CAUTION: running commands copied from a test script into the paused shell
156
+ # might result in files in your HOME being overwritten.
157
+ # -a
158
+ # Shortcut for -t -s -h
140
159
141
160
test_pause () {
142
- " $SHELL_PATH " < & 6 >&5 2>&7
161
+ PAUSE_TERM=$TERM &&
162
+ PAUSE_SHELL=$TEST_SHELL_PATH &&
163
+ PAUSE_HOME=$HOME &&
164
+ while test $# ! = 0
165
+ do
166
+ case " $1 " in
167
+ -t)
168
+ PAUSE_TERM=" $USER_TERM "
169
+ ;;
170
+ -s)
171
+ PAUSE_SHELL=" $SHELL "
172
+ ;;
173
+ -h)
174
+ PAUSE_HOME=" $USER_HOME "
175
+ ;;
176
+ -a)
177
+ PAUSE_TERM=" $USER_TERM "
178
+ PAUSE_SHELL=" $SHELL "
179
+ PAUSE_HOME=" $USER_HOME "
180
+ ;;
181
+ * )
182
+ break
183
+ ;;
184
+ esac
185
+ shift
186
+ done &&
187
+ TERM=" $PAUSE_TERM " HOME=" $PAUSE_HOME " " $PAUSE_SHELL " < & 6 >&5 2>&7
143
188
}
144
189
145
190
# Wrap git with a debugger. Adding this to a command can make it easier
146
191
# to understand what is going on in a failing test.
147
192
#
193
+ # Usage: debug [options] <git command>
194
+ # -d <debugger>
195
+ # --debugger=<debugger>
196
+ # Use <debugger> instead of GDB
197
+ # -t
198
+ # Use your original TERM instead of test-lib.sh's "dumb".
199
+ # This usually restores color output in the debugger.
200
+ # WARNING: the command being debugged might behave differently than when
201
+ # running the test.
202
+ #
148
203
# Examples:
149
204
# debug git checkout master
150
205
# debug --debugger=nemiver git $ARGS
151
206
# debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS
152
207
debug () {
153
- case " $1 " in
154
- -d)
155
- GIT_DEBUGGER=" $2 " &&
156
- shift 2
157
- ;;
158
- --debugger=* )
159
- GIT_DEBUGGER=" ${1#* =} " &&
160
- shift 1
161
- ;;
162
- * )
163
- GIT_DEBUGGER=1
164
- ;;
165
- esac &&
166
- GIT_DEBUGGER=" ${GIT_DEBUGGER} " " $@ " < & 6 >&5 2>&7
208
+ GIT_DEBUGGER=1 &&
209
+ DEBUG_TERM=$TERM &&
210
+ while test $# ! = 0
211
+ do
212
+ case " $1 " in
213
+ -t)
214
+ DEBUG_TERM=" $USER_TERM "
215
+ ;;
216
+ -d)
217
+ GIT_DEBUGGER=" $2 " &&
218
+ shift
219
+ ;;
220
+ --debugger=* )
221
+ GIT_DEBUGGER=" ${1#* =} "
222
+ ;;
223
+ * )
224
+ break
225
+ ;;
226
+ esac
227
+ shift
228
+ done &&
229
+
230
+ dotfiles=" .gdbinit .lldbinit"
231
+
232
+ for dotfile in $dotfiles
233
+ do
234
+ dotfile=" $USER_HOME /$dotfile " &&
235
+ test -f " $dotfile " && cp " $dotfile " " $HOME " || :
236
+ done &&
237
+
238
+ TERM=" $DEBUG_TERM " GIT_DEBUGGER=" ${GIT_DEBUGGER} " " $@ " < & 6 >&5 2>&7 &&
239
+
240
+ for dotfile in $dotfiles
241
+ do
242
+ rm -f " $HOME /$dotfile "
243
+ done
167
244
}
168
245
169
246
# Usage: test_commit [options] <message> [<file> [<contents> [<tag>]]]
0 commit comments