aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/test
diff options
context:
space:
mode:
authorGravatar dmarting <dmarting@google.com>2017-07-20 12:45:20 +0200
committerGravatar Klaus Aehlig <aehlig@google.com>2017-07-20 13:07:14 +0200
commit1711276d95f398a89ac501190f2158bcbb46b4dd (patch)
tree290450a0b4142665d7166402dc63246ab4c8dadf /tools/test
parentc3e0660bf8d5c6e32ae817f8a3f52c7fc6bf039e (diff)
Automated rollback of commit b8514f533d4546d3bfbec3700012f2bbeffd1c37.
*** Reason for rollback *** Breaks XML format when there is weird characters in the output (Jenkins fails to read XML output for re2 test) *** Original change description *** Add stdout to default XML file and generate XML file on timeout This should fix #1027 and get better error result on Jenkins. Change-Id: I5ce30b64f634e01dd350af10748c4a9455a6bea8 PiperOrigin-RevId: 162598130
Diffstat (limited to 'tools/test')
-rwxr-xr-xtools/test/test-setup.sh74
1 files changed, 27 insertions, 47 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index c43d5ee9c1..058c459cc1 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -140,42 +140,6 @@ if [[ -z "$no_echo" ]]; then
echo "-----------------------------------------------------------------------------"
fi
-function write_xml_output_file {
- local duration=$(expr $(date +%s) - $start)
- local errors=0
- local error_msg=
- local signal="${1-}"
- if [ -n "${XML_OUTPUT_FILE-}" -a ! -f "${XML_OUTPUT_FILE-}" ]; then
- # Create a default XML output file if the test runner hasn't generated it
- if [ -n "${signal}" ]; then
- errors=1
- if [ "${signal}" = "SIGTERM" ]; then
- error_msg="<error message=\"Timed out\"></error>"
- else
- error_msg="<error message=\"Terminated by signal ${signal}\"></error>"
- fi
- elif (( $exitCode != 0 )); then
- errors=1
- error_msg="<error message=\"exited with error code $exitCode\"></error>"
- fi
- # Ensure that test shards have unique names in the xml output.
- if [[ -n "${TEST_TOTAL_SHARDS+x}" ]] && ((TEST_TOTAL_SHARDS != 0)); then
- ((shard_num=TEST_SHARD_INDEX+1))
- TEST_NAME="$TEST_NAME"_shard_"$shard_num"/"$TEST_TOTAL_SHARDS"
- fi
- cat <<EOF >${XML_OUTPUT_FILE}
-<?xml version="1.0" encoding="UTF-8"?>
-<testsuites>
- <testsuite name="$TEST_NAME" tests="1" failures="0" errors="${errors}">
- <testcase name="$TEST_NAME" status="run" duration="${duration}">${error_msg}</testcase>
- <system-out>$(<"${XML_OUTPUT_FILE}.log")</system-out>
- </testsuite>
-</testsuites>
-EOF
- fi
- rm -f "${XML_OUTPUT_FILE}.log"
-}
-
# The path of this command-line is usually relative to the exec-root,
# but when using --run_under it can be a "/bin/bash -c" command-line.
@@ -197,21 +161,37 @@ fi
[[ -n "$RUNTEST_PRESERVE_CWD" ]] && EXE="${TEST_NAME}"
exitCode=0
-signals="$(trap -l | sed -E 's/[0-9]+\)//g')"
-for signal in $signals; do
- trap "write_xml_output_file ${signal}" ${signal}
-done
start=$(date +%s)
-
if [ -z "$COVERAGE_DIR" ]; then
- "${TEST_PATH}" "$@" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$?
+ "${TEST_PATH}" "$@" || exitCode=$?
else
- "$1" "$TEST_PATH" "${@:3}" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$?
+ "$1" "$TEST_PATH" "${@:3}" || exitCode=$?
fi
+duration=$(expr $(date +%s) - $start)
+
-for signal in $signals; do
- trap - ${signal}
-done
-write_xml_output_file
+if [ -n "${XML_OUTPUT_FILE-}" -a ! -f "${XML_OUTPUT_FILE-}" ]; then
+ # Create a default XML output file if the test runner hasn't generated it
+ if (( $exitCode != 0 )); then
+ errors=1
+ error_msg="<error message=\"exited with error code $exitCode\"></error>"
+ else
+ errors=0
+ error_msg=
+ fi
+ # Ensure that test shards have unique names in the xml output.
+ if [[ -n "${TEST_TOTAL_SHARDS+x}" ]] && ((TEST_TOTAL_SHARDS != 0)); then
+ ((shard_num=TEST_SHARD_INDEX+1))
+ TEST_NAME="$TEST_NAME"_shard_"$shard_num"/"$TEST_TOTAL_SHARDS"
+ fi
+ cat <<EOF >${XML_OUTPUT_FILE}
+<?xml version="1.0" encoding="UTF-8"?>
+<testsuites>
+ <testsuite name="$TEST_NAME" tests="1" failures="0" errors="$errors">
+ <testcase name="$TEST_NAME" status="run" duration="$duration">$error_msg</testcase>
+ </testsuite>
+</testsuites>
+EOF
+fi
exit $exitCode