View | Details | Raw Unified | Return to bug 27059
Collapse All | Expand All

(-)a/libshell.spec (-1 / +6 lines)
Lines 1-6 Link Here
1
Name: libshell
1
Name: libshell
2
Version: 0.1.6
2
Version: 0.1.6
3
Release: alt1
3
Release: alt1.imz1
4
4
5
Summary:  A library of shell functions
5
Summary:  A library of shell functions
6
License: GPL
6
License: GPL
Lines 28-33 This package contains common functions for shell projects to increase code reuse Link Here
28
%doc COPYING SYMS
28
%doc COPYING SYMS
29
29
30
%changelog
30
%changelog
31
* Fri Mar 02 2012 Ivan Zakharyaschev <imz@altlinux.org> 0.1.6-alt1.imz1
32
- shell-unittest changes:
33
  + Output debugging info if the test aborts with a strange exit
34
    status.
35
31
* Wed Jul 27 2011 Alexey Gladkov <legion@altlinux.org> 0.1.6-alt1
36
* Wed Jul 27 2011 Alexey Gladkov <legion@altlinux.org> 0.1.6-alt1
32
- shell-ini-config changes (ALT#25946):
37
- shell-ini-config changes (ALT#25946):
33
  + Fix comment formatting (thx Vladislav Zavjalov);
38
  + Fix comment formatting (thx Vladislav Zavjalov);
(-)a/libshell/shell-unittest (-2 / +45 lines)
Lines 193-199 messageTest() { Link Here
193
		0) printf '[done]' ;;
193
		0) printf '[done]' ;;
194
		1) printf '[FAIL]' ;;
194
		1) printf '[FAIL]' ;;
195
		2) printf '[skip]' ;;
195
		2) printf '[skip]' ;;
196
		*) printf '[status=%s]' $3 ;;
196
		*) printf '[status=%s%s]' "$3" "${debug:+, to be run again with debugging output}" ;;
197
	esac
197
	esac
198
	printf ' (%s) %s\n' "$1" "$2"
198
	printf ' (%s) %s\n' "$1" "$2"
199
}
199
}
Lines 225-243 runUnitTests() { Link Here
225
	__shell_unit_tests="$(printf '%s\n' "$__shell_unit_tests" |sort -u)"
225
	__shell_unit_tests="$(printf '%s\n' "$__shell_unit_tests" |sort -u)"
226
	set -- ${__shell_unit_tests-}
226
	set -- ${__shell_unit_tests-}
227
227
228
	local retval=0 rc passed=0 failed=0 skipped=0 total="$#"
228
	local retval=0 rc debug passed=0 failed=0 skipped=0 total="$#"
229
229
230
	while [ "$#" -gt 0 ]; do
230
	while [ "$#" -gt 0 ]; do
231
		run_or_exit setUp
231
		run_or_exit setUp
232
232
233
		if [ -n "$debug" ]; then
234
		    set -x
235
		fi
233
		rc=0
236
		rc=0
234
		msg="$("$1")" || rc=$?
237
		msg="$("$1")" || rc=$?
238
		set +x
235
239
236
		case "$rc" in
240
		case "$rc" in
237
			0) passed=$(($passed+1)) ;;
241
			0) passed=$(($passed+1)) ;;
238
			1) failed=$(($failed+1)); retval=1; ;;
242
			1) failed=$(($failed+1)); retval=1; ;;
239
			2) skipped=$(($skipped+1)) ;;
243
			2) skipped=$(($skipped+1)) ;;
244
		        *) 
245
			# Smth unexpected has happened during the test. We are about to output the debugging info.
246
			# 
247
			# Motivating example:
248
			#
249
			# I couldn't figure out why one of my tests for gear--when run in hasher--reported this strange
250
			# exit status (whereas when done by a simple "rpm -bb", the test passed).
251
			# 
252
			# With the debugging info now, it looks like this:
253
			#
254
                        # make: Entering directory `/usr/src/RPM/BUILD/gear-1.7.2.6'
255
                        # cd tests && ./run
256
                        # [status=128, to be run again with debugging output] (gear_import_check_lost_cwd) 
257
                        # + rc=0
258
                        # ++ gear_import_check_lost_cwd
259
                        # ++ finalize_repo=
260
                        # ++ gear_import_check_lost
261
                        # ++ local v
262
                        # ++ mkdir -p .git/.work
263
                        # + msg=
264
                        # + rc=128
265
                        # + set +x
266
                        # [status=128] (gear_import_check_lost_cwd) 
267
			# 
268
			# And I'm able to find the point in the script where this happens.
269
			# (The explanation for the strange exit status was probably a bashism there.)
270
			if [ -z "$debug" ]; then 
271
			    debug=1
272
			    # messageTest will explain that the test will be re-run:
273
			    run_or_exit messageTest "$1" "$msg" "$rc"
274
			    run_or_exit tearDown
275
			    continue
276
			else
277
			    # It's safer to fail in this case (to draw the attention of the maintainer).
278
			    failed=$(($failed+1)); retval=1
279
			fi
280
			;;
240
		esac
281
		esac
282
		# Clear the debug flag, because we have just run the last test with the debug switched on, if needed.
283
		debug=
241
		run_or_exit messageTest "$1" "$msg" "$rc"
284
		run_or_exit messageTest "$1" "$msg" "$rc"
242
285
243
		run_or_exit tearDown
286
		run_or_exit tearDown

Return to bug 27059