Updated shunit2 to 2.1.7pre

pull/36/head
deajan 9 years ago
parent 743a6c807a
commit 17c8bab444

@ -1,5 +1,7 @@
#!/bin/bash
TEST_BUILD=2015070201
cd -P -- "$(dirname -- "$0")"
OSYNC_EXECUTABLE=$(readlink -e ../osync.sh)
declare -A sandbox_osync

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2 335 2011-05-01 20:10:33Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -15,20 +15,31 @@
# return if shunit already loaded
[ -n "${SHUNIT_VERSION:-}" ] && exit 0
SHUNIT_VERSION='2.1.7pre'
SHUNIT_VERSION='2.1.6'
# return values that scripts can use
SHUNIT_TRUE=0
SHUNIT_FALSE=1
SHUNIT_ERROR=2
# enable strict mode by default
SHUNIT_STRICT=${SHUNIT_STRICT:-${SHUNIT_TRUE}}
# logging functions
_shunit_warn() { echo "shunit2:WARN $@" >&2; }
_shunit_error() { echo "shunit2:ERROR $@" >&2; }
_shunit_fatal() { echo "shunit2:FATAL $@" >&2; exit ${SHUNIT_ERROR}; }
# determine some reasonable command defaults
__SHUNIT_UNAME_S=`uname -s`
case "${__SHUNIT_UNAME_S}" in
BSD) __SHUNIT_EXPR_CMD='gexpr' ;;
*) __SHUNIT_EXPR_CMD='expr' ;;
esac
# commands a user can override if needed
SHUNIT_EXPR_CMD=${SHUNIT_EXPR_CMD:-${__SHUNIT_EXPR_CMD}}
# enable strict mode by default
SHUNIT_STRICT=${SHUNIT_STRICT:-${SHUNIT_TRUE}}
# specific shell checks
if [ -n "${ZSH_VERSION:-}" ]; then
setopt |grep "^shwordsplit$" >/dev/null
@ -51,19 +62,24 @@ __SHUNIT_MODE_STANDALONE='standalone'
__SHUNIT_PARENT=${SHUNIT_PARENT:-$0}
# set the constants readonly
shunit_constants_=`set |grep '^__SHUNIT_' |cut -d= -f1`
echo "${shunit_constants_}" |grep '^Binary file' >/dev/null && \
shunit_constants_=`set |grep -a '^__SHUNIT_' |cut -d= -f1`
for shunit_constant_ in ${shunit_constants_}; do
shunit_ro_opts_=''
case ${ZSH_VERSION:-} in
'') ;; # this isn't zsh
[123].*) ;; # early versions (1.x, 2.x, 3.x)
*) shunit_ro_opts_='-g' ;; # all later versions. declare readonly globally
esac
readonly ${shunit_ro_opts_} ${shunit_constant_}
__shunit_constants=`set |grep '^__SHUNIT_' |cut -d= -f1`
echo "${__shunit_constants}" |grep '^Binary file' >/dev/null && \
__shunit_constants=`set |grep -a '^__SHUNIT_' |cut -d= -f1`
for __shunit_const in ${__shunit_constants}; do
if [ -z "${ZSH_VERSION:-}" ]; then
readonly ${__shunit_const}
else
case ${ZSH_VERSION} in
[123].*) readonly ${__shunit_const} ;;
*) readonly -g ${__shunit_const} # declare readonly constants globally
esac
fi
done
unset shunit_constant_ shunit_constants_ shunit_ro_opts_
unset __shunit_const __shunit_constants
#
# internal variables
#
# variables
__shunit_lineno='' # line number of executed test
@ -88,6 +104,9 @@ __shunit_assertsSkipped=0
# macros
_SHUNIT_LINENO_='eval __shunit_lineno=""; if [ "${1:-}" = "--lineno" ]; then [ -n "$2" ] && __shunit_lineno="[$2] "; shift 2; fi'
#-----------------------------------------------------------------------------
# private functions
#-----------------------------------------------------------------------------
# assert functions
#
@ -313,8 +332,8 @@ _ASSERT_NOT_SAME_='eval assertNotSame --lineno "${LINENO:-}"'
assertTrue()
{
${_SHUNIT_LINENO_}
if [ $# -gt 2 ]; then
_shunit_error "assertTrue() takes one two arguments; $# given"
if [ $# -lt 1 -o $# -gt 2 ]; then
_shunit_error "assertTrue() takes one or two arguments; $# given"
return ${SHUNIT_ERROR}
fi
_shunit_shouldSkip && return ${SHUNIT_TRUE}

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test.sh 322 2011-04-24 00:09:45Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test_asserts.sh 312 2011-03-14 22:41:29Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -196,10 +196,7 @@ testAssertFalse()
oneTimeSetUp()
{
tmpDir="${__shunit_tmpDir}/output"
mkdir "${tmpDir}"
stdoutF="${tmpDir}/stdout"
stderrF="${tmpDir}/stderr"
th_oneTimeSetUp
MSG='This is a test message'
}

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test_failures.sh 286 2008-11-24 21:42:34Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -76,10 +76,7 @@ testFailSame()
oneTimeSetUp()
{
tmpDir="${__shunit_tmpDir}/output"
mkdir "${tmpDir}"
stdoutF="${tmpDir}/stdout"
stderrF="${tmpDir}/stderr"
th_oneTimeSetUp
MSG='This is a test message'
}

@ -1,4 +1,4 @@
# $Id: shunit2_test_helpers 286 2008-11-24 21:42:34Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -52,6 +52,15 @@ th_fatal() { echo "${MY_NAME}:FATAL $@" >&2; }
# output subtest name
th_subtest() { echo " $@" >&2; }
th_oneTimeSetUp()
{
# these files will be cleaned up automatically by shUnit2
stdoutF="${SHUNIT_TMPDIR}/stdout"
stderrF="${SHUNIT_TMPDIR}/stderr"
returnF="${SHUNIT_TMPDIR}/return"
expectedF="${SHUNIT_TMPDIR}/expected"
}
# generate a random number
th_generateRandom()
{
@ -141,6 +150,8 @@ th_assertFalseWithOutput()
"[ -s '${th_stdout_}' ]"
assertFalse "${th_test_}; expected no output to STDERR" \
"[ -s '${th_stderr_}' ]"
[ -s "${th_stdout_}" -a ! -s "${th_stderr_}" ] || \
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
}
@ -165,10 +176,51 @@ th_assertFalseWithError()
"[ -s '${th_stdout_}' ]"
assertTrue "${th_test_}; expected output to STDERR" \
"[ -s '${th_stderr_}' ]"
[ ! -s "${th_stdout_}" -a -s "${th_stderr_}" ] || \
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
}
# Some shells, zsh on Solaris in particular, return immediately from a sub-shell
# when a non-zero return value is encountered. To properly catch these values,
# they are either written to disk, or recognized as an error the file is empty.
th_clearReturn() { cp /dev/null "${returnF}"; }
th_queryReturn()
{
if [ -s "${returnF}" ]; then
th_return=`cat "${returnF}"`
else
th_return=${SHUNIT_ERROR}
fi
}
# Providing external and internal calls to the showOutput helper function.
th_showOutput() { _th_showOutput $@; }
_th_showOutput()
{
_th_return_=$1
_th_stdout_=$2
_th_stderr_=$3
isSkipping
if [ $? -eq ${SHUNIT_FALSE} -a ${_th_return_} != ${SHUNIT_TRUE} ]; then
if [ -n "${_th_stdout_}" -a -s "${_th_stdout_}" ]; then
echo '>>> STDOUT' >&2
cat "${_th_stdout_}" >&2
fi
if [ -n "${_th_stderr_}" -a -s "${_th_stderr_}" ]; then
echo '>>> STDERR' >&2
cat "${_th_stderr_}" >&2
fi
if [ -n "${_th_stdout_}" -o -n "${_th_stderr_}" ]; then
echo '<<< end output' >&2
fi
fi
unset _th_return_ _th_stdout_ _th_stderr_
}
#
# main
#

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test_macros.sh 299 2010-05-03 12:44:20Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -238,10 +238,7 @@ testFailNotSame()
oneTimeSetUp()
{
tmpDir="${__shunit_tmpDir}/output"
mkdir "${tmpDir}"
stdoutF="${tmpDir}/stdout"
stderrF="${tmpDir}/stderr"
th_oneTimeSetUp
}
# load and run shUnit2

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test_misc.sh 322 2011-04-24 00:09:45Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2008 Kate Ward. All Rights Reserved.
@ -20,6 +20,7 @@
# incorrectly interpret the embedded functions as real functions.
testUnboundVariable()
{
unittestF="${SHUNIT_TMPDIR}/unittest"
sed 's/^#//' >"${unittestF}" <<EOF
## treat unset variables as an error when performing parameter expansion
#set -u
@ -116,7 +117,7 @@ testEscapeCharInStr_specialChars()
# treated as real functions by shUnit2.
testExtractTestFunctions()
{
f="${tmpD}/extract_test_functions"
f="${SHUNIT_TMPDIR}/extract_test_functions"
sed 's/^#//' <<EOF >"${f}"
#testABC() { echo 'ABC'; }
#test_def() {
@ -147,17 +148,11 @@ setUp()
for f in ${expectedF} ${stdoutF} ${stderrF}; do
cp /dev/null ${f}
done
rm -fr "${tmpD}"
mkdir "${tmpD}"
}
oneTimeSetUp()
{
tmpD="${SHUNIT_TMPDIR}/tmp"
expectedF="${SHUNIT_TMPDIR}/expected"
stdoutF="${SHUNIT_TMPDIR}/stdout"
stderrF="${SHUNIT_TMPDIR}/stderr"
unittestF="${SHUNIT_TMPDIR}/unittest"
th_oneTimeSetUp
}
# load and run shUnit2

@ -1,5 +1,5 @@
#! /bin/sh
# $Id: shunit2_test_standalone.sh 303 2010-05-03 13:11:27Z kate.ward@forestent.com $
# $Id$
# vim:et:ft=sh:sts=2:sw=2
#
# Copyright 2010 Kate Ward. All Rights Reserved.

Loading…
Cancel
Save