add some test status helpers to simplify management of i/o and exit status
authorMike Frysinger <vapier@gentoo.org>
Thu, 15 Dec 2011 00:15:09 +0000 (00:15 +0000)
committerMike Frysinger <vapier@gentoo.org>
Thu, 15 Dec 2011 00:15:09 +0000 (00:15 +0000)
eclass/tests/autotools:eaclocal_amflags.sh
eclass/tests/eutils:path_exists.sh
eclass/tests/scons-utils.sh
eclass/tests/tests-common.sh
eclass/tests/toolchain-funcs.sh

index ac0ab767aa55410c8e14b387373097e88b5e7003..18656562905159bac0dda342fcfdea00e59f52a1 100755 (executable)
@@ -5,11 +5,11 @@ source tests-common.sh
 inherit autotools
 
 test-it() {
-       ebegin "Testing eaclocal_amflags $1: $2"
+       tbegin "eaclocal_amflags $1: $2"
        printf "ACLOCAL_AMFLAGS = %b\n" "$2" > Makefile.am
        local flags=$(eaclocal_amflags) exp=${3:-$2}
        [[ "${flags}" == "${exp}" ]]
-       if ! eend $? ; then
+       if ! tend $? ; then
                printf '### INPUT:\n%s\n' "$2"
                printf '### FILE:\n%s\n' "$(<Makefile.am)"
                printf '### EXPECTED:\n%s\n' "${exp}"
@@ -25,3 +25,5 @@ test-it shell-exec '`echo hi`' "hi"
 test-it shell-exec '`echo {0..3}`' "0 1 2 3"
 
 test-it multiline '-I oneline \\\n\t-I twoline' "-I oneline -I twoline"
+
+texit
index 5260b268edb07efe417ab19ee2037afc1ea5423f..9d1ddfc2f1d602d5fa5d6cbbbff80d76d02454ea 100755 (executable)
@@ -4,15 +4,12 @@ source tests-common.sh
 
 inherit eutils
 
-tret=0
-
 test-path_exists() {
        local exp=$1; shift
-       ebegin "Testing path_exists($*) == ${exp}"
+       tbegin "path_exists($*) == ${exp}"
        path_exists "$@"
        [[ ${exp} -eq $? ]]
-       eend $?
-       : $(( tret |= $? ))
+       tend $?
 }
 
 test-path_exists 1
@@ -33,4 +30,4 @@ test-path_exists 1 ${good} ${bad}
 test-path_exists 1 -a ${good} ${bad}
 test-path_exists 0 -o ${good} ${bad}
 
-(exit ${tret})
+texit
index e8c60ff7839378ebb60e4b85242994fc797f94aa..345f0a401c23c4135d6ee8e29f363a090d78872f 100755 (executable)
@@ -26,7 +26,7 @@ jc=5
 # failed test counter
 failed=0
 
-ebegin "Testing scons_clean_makeopts()"
+tbegin "scons_clean_makeopts()"
 
 # sane MAKEOPTS
 test-scons_clean_makeopts '--jobs=14 -k'
@@ -56,4 +56,6 @@ test-scons_clean_makeopts '--jobs funnystuff -k' "--jobs=${jc} -k"
 test-scons_clean_makeopts '--jobs -l3' "--jobs=${jc}"
 test-scons_clean_makeopts '-j -l3' "-j ${jc}"
 
-eend ${failed}
+tend ${failed}
+
+texit
index 5413d7ec4cdbe13a971177a73f3823350b6b8fe8..3b1ffab5d7649094e296c6ba7b7669b70cf090ba 100644 (file)
@@ -87,3 +87,15 @@ KV_to_int() {
 
        return 1
 }
+
+tret=0
+tbegin() {
+       ebegin "Testing $*"
+}
+texit() {
+       exit ${tret}
+}
+tend() {
+       eend "$@"
+       : $(( tret |= $? ))
+}
index 73dadbb20154c46899fb55a19c5feabcbeb5a55b..d8fb97e5bc73925ebb296cfdd09fb0eecf69691b 100755 (executable)
@@ -22,23 +22,23 @@ test-tc-arch-kernel() {
        done
        return ${ret}
 }
-ebegin "Testing tc-arch-kernel() (KV=2.6.0)"
+tbegin "tc-arch-kernel() (KV=2.6.0)"
 test-tc-arch-kernel 2.6.0 \
        alpha arm{,eb}:arm avr32 bfin:blackfin cris hppa:parisc \
        i{3..6}86:i386 ia64 m68k mips{,eb}:mips nios2 powerpc:ppc powerpc64:ppc64 \
        s390{,x}:s390 sh{1..4}{,eb}:sh sparc{,64} vax x86_64 \
        i{3..6}86-gentoo-freebsd:i386
-eend $?
-ebegin "Testing tc-arch-kernel() (KV=2.6.30)"
+tend $?
+tbegin "tc-arch-kernel() (KV=2.6.30)"
 test-tc-arch-kernel 2.6.30 \
        i{3..6}86:x86 x86_64:x86 \
        powerpc{,64}:powerpc i{3..6}86-gentoo-freebsd:i386
-eend $?
+tend $?
 
 #
 # TEST: tc-arch
 #
-ebegin "Testing tc-arch"
+tbegin "tc-arch"
 ret=0
 for CHOST in \
        alpha arm{,eb}:arm avr32:avr bfin cris hppa i{3..6}86:x86 ia64 m68k \
@@ -54,4 +54,6 @@ do
                ((++ret))
        fi
 done
-eend ${ret}
+tend ${ret}
+
+texit