|
|
@@ -24,10 +24,10 @@ |
|
|
|
### |
|
|
|
|
|
|
|
asserts=00; errors=0; total=0; content="" |
|
|
|
date=`which gdate 2>/dev/null || which date` |
|
|
|
date="$(which gdate 2>/dev/null || which date)" |
|
|
|
|
|
|
|
# default output folder |
|
|
|
juDIR=`pwd`/results |
|
|
|
juDIR="$(pwd)/results" |
|
|
|
|
|
|
|
# The name of the suite is calculated based in your script name |
|
|
|
suite="" |
|
|
@@ -59,18 +59,18 @@ function juLogClean() { |
|
|
|
function juLog() { |
|
|
|
suite=""; |
|
|
|
errfile=/tmp/evErr.$$.log |
|
|
|
date=`which gdate 2>/dev/null || which date` |
|
|
|
date="$(which gdate 2>/dev/null || which date)" |
|
|
|
asserts=00; errors=0; total=0; content="" |
|
|
|
|
|
|
|
# parse arguments |
|
|
|
ya=""; icase="" |
|
|
|
while [[ -z "$ya" ]]; do |
|
|
|
case "$1" in |
|
|
|
-name=*) name=`echo "$1" | ${SED} -e 's/-name=//'`; shift;; |
|
|
|
-class=*) class=`echo "$1" | ${SED} -e 's/-class=//'`; shift;; |
|
|
|
-ierror=*) ereg=`echo "$1" | ${SED} -e 's/-ierror=//'`; icase="-i"; shift;; |
|
|
|
-error=*) ereg=`echo "$1" | ${SED} -e 's/-error=//'`; shift;; |
|
|
|
-output=*) juDIR=`echo "$1" | ${SED} -e 's/-output=//'`; shift;; |
|
|
|
-name=*) name="$(echo "$1" | ${SED} -e 's/-name=//')"; shift;; |
|
|
|
-class=*) class="$(echo "$1" | ${SED} -e 's/-class=//')"; shift;; |
|
|
|
-ierror=*) ereg="$(echo "$1" | ${SED} -e 's/-ierror=//')"; icase="-i"; shift;; |
|
|
|
-error=*) ereg="$(echo "$1" | ${SED} -e 's/-error=//')"; shift;; |
|
|
|
-output=*) juDIR="$(echo "$1" | ${SED} -e 's/-output=//')"; shift;; |
|
|
|
*) ya=1;; |
|
|
|
esac |
|
|
|
done |
|
|
@@ -101,37 +101,37 @@ function juLog() { |
|
|
|
# eval the command sending output to a file |
|
|
|
outf=/var/tmp/ju$$.txt |
|
|
|
errf=/var/tmp/ju$$-err.txt |
|
|
|
>${outf} |
|
|
|
:>${outf} |
|
|
|
echo "" | tee -a ${outf} |
|
|
|
echo "+++ Running case: ${class}.${name} " | tee -a ${outf} |
|
|
|
echo "+++ working dir: "`pwd` | tee -a ${outf} |
|
|
|
echo "+++ working dir: $(pwd)" | tee -a ${outf} |
|
|
|
echo "+++ command: ${cmd}" | tee -a ${outf} |
|
|
|
ini=`${date} +%s.%N` |
|
|
|
ini="$(${date} +%s.%N)" |
|
|
|
# execute the command, temporarily swapping stderr and stdout so they can be tee'd to separate files, |
|
|
|
# then swapping them back again so that the streams are written correctly for the invoking process |
|
|
|
( (eVal "${cmd}" | tee -a ${outf}) 3>&1 1>&2 2>&3 | tee ${errf}) 3>&1 1>&2 2>&3 |
|
|
|
evErr=`cat ${errfile}` |
|
|
|
evErr="$(cat ${errfile})" |
|
|
|
rm -f ${errfile} |
|
|
|
end=`${date} +%s.%N` |
|
|
|
end="$(${date} +%s.%N)" |
|
|
|
echo "+++ exit code: ${evErr}" | tee -a ${outf} |
|
|
|
|
|
|
|
# set the appropriate error, based in the exit code and the regex |
|
|
|
[[ ${evErr} != 0 ]] && err=1 || err=0 |
|
|
|
out=`cat $outf | ${SED} -e 's/^\([^+]\)/| \1/g'` |
|
|
|
if [ ${err} = 0 -a -n "${ereg:-}" ]; then |
|
|
|
H=`echo "${out}" | egrep ${icase} "${ereg}"` |
|
|
|
out="$(${SED} -e 's/^\([^+]\)/| \1/g' "$outf")" |
|
|
|
if [ ${err} = 0 ] && [ -n "${ereg:-}" ]; then |
|
|
|
H=$(echo "${out}" | grep -E ${icase} "${ereg}") |
|
|
|
[[ -n "${H}" ]] && err=1 |
|
|
|
fi |
|
|
|
[[ ${err} != 0 ]] && echo "+++ error: ${err}" | tee -a ${outf} |
|
|
|
rm -f ${outf} |
|
|
|
|
|
|
|
errMsg=`cat ${errf}` |
|
|
|
errMsg=$(cat ${errf}) |
|
|
|
rm -f ${errf} |
|
|
|
# calculate vars |
|
|
|
asserts=$(($asserts+1)) |
|
|
|
errors=$(($errors+$err)) |
|
|
|
time=`echo "${end} ${ini}" | awk '{print $1 - $2}'` |
|
|
|
total=`echo "${total} ${time}" | awk '{print $1 + $2}'` |
|
|
|
asserts=$((asserts+1)) |
|
|
|
errors=$((errors+err)) |
|
|
|
time=$(echo "${end} ${ini}" | awk '{print $1 - $2}') |
|
|
|
total=$(echo "${total} ${time}" | awk '{print $1 + $2}') |
|
|
|
|
|
|
|
# write the junit xml report |
|
|
|
## failure tag |
|
|
@@ -149,14 +149,14 @@ function juLog() { |
|
|
|
|
|
|
|
if [[ -e "${juDIR}/junit_${suite}.xml" ]]; then |
|
|
|
# file exists. first update the failures count |
|
|
|
failCount=`${SED} -n "s/.*testsuite.*failures=\"\([0-9]*\)\".*/\1/p" "${juDIR}/junit_${suite}.xml"` |
|
|
|
errors=$(($failCount+$errors)) |
|
|
|
failCount=$(${SED} -n "s/.*testsuite.*failures=\"\([0-9]*\)\".*/\1/p" "${juDIR}/junit_${suite}.xml") |
|
|
|
errors=$((failCount+errors)) |
|
|
|
${SED} -i "0,/failures=\"${failCount}\"/ s/failures=\"${failCount}\"/failures=\"${errors}\"/" "${juDIR}/junit_${suite}.xml" |
|
|
|
${SED} -i "0,/errors=\"${failCount}\"/ s/errors=\"${failCount}\"/errors=\"${errors}\"/" "${juDIR}/junit_${suite}.xml" |
|
|
|
|
|
|
|
# file exists. Need to append to it. If we remove the testsuite end tag, we can just add it in after. |
|
|
|
${SED} -i "s^</testsuite>^^g" ${juDIR}/junit_${suite}.xml ## remove testSuite so we can add it later |
|
|
|
${SED} -i "s^</testsuites>^^g" ${juDIR}/junit_${suite}.xml |
|
|
|
${SED} -i "s^</testsuite>^^g" "${juDIR}/junit_${suite}.xml" ## remove testSuite so we can add it later |
|
|
|
${SED} -i "s^</testsuites>^^g" "${juDIR}/junit_${suite}.xml" |
|
|
|
cat <<EOF >> "$juDIR/junit_$suite.xml" |
|
|
|
${content:-} |
|
|
|
</testsuite> |
|
|
|
0 comments on commit
9e719d8