ALT Linux Bugzilla
– Attachment 5375 Details for
Bug 27059
output debugging info if a test aborts with a strange exit status
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
git diff upstream...unittest/debug-strange-status
libshell-unittest-debug-strange-status.patch (text/plain), 3.41 KB, created by
Ivan Zakharyaschev
on 2012-03-12 08:38:29 MSK
(
hide
)
Description:
git diff upstream...unittest/debug-strange-status
Filename:
MIME Type:
Creator:
Ivan Zakharyaschev
Created:
2012-03-12 08:38:29 MSK
Size:
3.41 KB
patch
obsolete
>diff --git a/libshell.spec b/libshell.spec >index 2efdb4f..2380601 100644 >--- a/libshell.spec >+++ b/libshell.spec >@@ -1,6 +1,6 @@ > Name: libshell > Version: 0.1.6 >-Release: alt1 >+Release: alt1.imz1 > > Summary: A library of shell functions > License: GPL >@@ -28,6 +28,11 @@ This package contains common functions for shell projects to increase code reuse > %doc COPYING SYMS > > %changelog >+* Fri Mar 02 2012 Ivan Zakharyaschev <imz@altlinux.org> 0.1.6-alt1.imz1 >+- shell-unittest changes: >+ + Output debugging info if the test aborts with a strange exit >+ status. >+ > * Wed Jul 27 2011 Alexey Gladkov <legion@altlinux.org> 0.1.6-alt1 > - shell-ini-config changes (ALT#25946): > + Fix comment formatting (thx Vladislav Zavjalov); >diff --git a/libshell/shell-unittest b/libshell/shell-unittest >index 67cb0c5..bfd35b8 100644 >--- a/libshell/shell-unittest >+++ b/libshell/shell-unittest >@@ -193,7 +193,7 @@ messageTest() { > 0) printf '[done]' ;; > 1) printf '[FAIL]' ;; > 2) printf '[skip]' ;; >- *) printf '[status=%s]' $3 ;; >+ *) printf '[status=%s%s]' "$3" "${debug:+, to be run again with debugging output}" ;; > esac > printf ' (%s) %s\n' "$1" "$2" > } >@@ -225,19 +225,62 @@ runUnitTests() { > __shell_unit_tests="$(printf '%s\n' "$__shell_unit_tests" |sort -u)" > set -- ${__shell_unit_tests-} > >- local retval=0 rc passed=0 failed=0 skipped=0 total="$#" >+ local retval=0 rc debug passed=0 failed=0 skipped=0 total="$#" > > while [ "$#" -gt 0 ]; do > run_or_exit setUp > >+ if [ -n "$debug" ]; then >+ set -x >+ fi > rc=0 > msg="$("$1")" || rc=$? >+ set +x > > case "$rc" in > 0) passed=$(($passed+1)) ;; > 1) failed=$(($failed+1)); retval=1; ;; > 2) skipped=$(($skipped+1)) ;; >+ *) >+ # Smth unexpected has happened during the test. We are about to output the debugging info. >+ # >+ # Motivating example: >+ # >+ # I couldn't figure out why one of my tests for gear--when run in hasher--reported this strange >+ # exit status (whereas when done by a simple "rpm -bb", the test passed). >+ # >+ # With the debugging info now, it looks like this: >+ # >+ # make: Entering directory `/usr/src/RPM/BUILD/gear-1.7.2.6' >+ # cd tests && ./run >+ # [status=128, to be run again with debugging output] (gear_import_check_lost_cwd) >+ # + rc=0 >+ # ++ gear_import_check_lost_cwd >+ # ++ finalize_repo= >+ # ++ gear_import_check_lost >+ # ++ local v >+ # ++ mkdir -p .git/.work >+ # + msg= >+ # + rc=128 >+ # + set +x >+ # [status=128] (gear_import_check_lost_cwd) >+ # >+ # And I'm able to find the point in the script where this happens. >+ # (The explanation for the strange exit status was probably a bashism there.) >+ if [ -z "$debug" ]; then >+ debug=1 >+ # messageTest will explain that the test will be re-run: >+ run_or_exit messageTest "$1" "$msg" "$rc" >+ run_or_exit tearDown >+ continue >+ else >+ # It's safer to fail in this case (to draw the attention of the maintainer). >+ failed=$(($failed+1)); retval=1 >+ fi >+ ;; > esac >+ # Clear the debug flag, because we have just run the last test with the debug switched on, if needed. >+ debug= > run_or_exit messageTest "$1" "$msg" "$rc" > > run_or_exit tearDown
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 27059
: 5375