TT#4590 generate unique id for JUNIT output

Change-Id: Id4a60f8abd7dd1a308ca1d1e980b7fad599d50c7
changes/26/8926/2
Victor Seva 9 years ago
parent 31dd6f2b81
commit 7b6c758ff1

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
RESULTS=${RESULTS:-.} RESULTS=${RESULTS:-.}
ID=0
if [ -z "${FORMAT}" ] ; then if [ -z "${FORMAT}" ] ; then
FORMAT=TAP FORMAT=TAP
@ -16,10 +17,20 @@ esac
mkdir -p "${RESULTS}"/reports mkdir -p "${RESULTS}"/reports
rm -rf "${RESULTS}"/reports/* rm -rf "${RESULTS}"/reports/*
# unique id across files
# See TT#4590
function fix_id() {
(( ID += 1))
local tmp_id
tmp_id=$(printf "%05d\n" "$ID")
sed -i "s/id=\"00001\"/id=\"$tmp_id\"/" "$1"
}
function do_test() { function do_test() {
echo "testing $1 -> ${RESULTS}/reports/${1}.${EXT}" local RES="${RESULTS}/reports/${1}.${EXT}"
echo "testing $1 -> ${RES}"
if ${OUT_FORCE} ; then if ${OUT_FORCE} ; then
cat<<EOF|lua5.1 - > ${RESULTS}/reports/${1}.${EXT} cat<<EOF |lua5.1 - > "${RES}"
EXPORT_ASSERT_TO_GLOBALS = true EXPORT_ASSERT_TO_GLOBALS = true
require "tests/${1}" require "tests/${1}"
---- Control test output: ---- Control test output:
@ -29,23 +40,27 @@ lu:setVerbosity(1)
lu:run() lu:run()
EOF EOF
else else
cat<<EOF|lua5.1 - cat<<EOF |lua5.1 -
EXPORT_ASSERT_TO_GLOBALS = true EXPORT_ASSERT_TO_GLOBALS = true
require "tests/${1}" require "tests/${1}"
---- Control test output: ---- Control test output:
local lu = LuaUnit local lu = LuaUnit
lu:setOutputType('${FORMAT}') lu:setOutputType('${FORMAT}')
lu:setFname('${RESULTS}/reports/${1}.${EXT}') lu:setFname('${RES}')
lu:setVerbosity(1) lu:setVerbosity(1)
lu:run() lu:run()
EOF EOF
if [[ "${FORMAT}" = "JUNIT" ]] ; then
fix_id "${RES}"
fi
fi fi
} }
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
for i in $@; do for i in "$@"; do
if [ ! -f "$i" ]; then if [ ! -f "$i" ]; then
echo "No $f found" echo "No $i found"
else else
do_test "$(basename "$i" .lua)" do_test "$(basename "$i" .lua)"
fi fi
@ -53,6 +68,6 @@ if [[ -n "$@" ]]; then
exit 0 exit 0
fi fi
for i in $(find tests -name '*.lua' ! -name test_\*) ; do find tests -name '*.lua' ! -name test_\*| while read -r i ; do
do_test "$(basename "$i" .lua)" do_test "$(basename "$i" .lua)"
done done

@ -17,6 +17,4 @@ else
mkdir -p "${RESULTS}" mkdir -p "${RESULTS}"
fi fi
source_path="$(pwd)"
RESULTS=${RESULTS} FORMAT=JUNIT ./run_tests.sh RESULTS=${RESULTS} FORMAT=JUNIT ./run_tests.sh

Loading…
Cancel
Save