aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/test
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2018-02-22 02:47:42 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-22 02:49:51 -0800
commiteb067ea88749a5635cc8ee8954cde2b767f1eb61 (patch)
tree31b7c527c07932c796ca5738c3632e81e18c353d /tools/test
parent93a6730d30f1e0d59d7d01788ea47c2171d1085a (diff)
Fix test name in fallback xml when --run_under is used.
When --run_under is used, the run-under wrapper will be injected in front of the normal test command line. So, it's incorrect to use the beginning of the command line to infer the test name. However, we can always get the underlying test executable with the TEST_BINARY environmental variable. Rename TEST_NAME to EXE to avoid future confusion. Fixes https://github.com/bazelbuild/bazel/issues/4588. Change-Id: I6fd05cca5e5441c13ee16290c4028ec84adec983 PiperOrigin-RevId: 186590311
Diffstat (limited to 'tools/test')
-rwxr-xr-xtools/test/test-setup.sh19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index 002edb8bdf..bb411c9268 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -160,6 +160,7 @@ function write_xml_output_file {
local errors=0
local error_msg=
local signal="${1-}"
+ local test_name=
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
@@ -173,16 +174,17 @@ function write_xml_output_file {
errors=1
error_msg="<error message=\"exited with error code $exitCode\"></error>"
fi
+ test_name="${TEST_BINARY#./}"
# 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"
+ 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 name="$test_name" tests="1" failures="0" errors="${errors}">
+ <testcase name="$test_name" status="run" duration="${duration}">${error_msg}</testcase>
<system-out><![CDATA[$(encode_output_file "${XML_OUTPUT_FILE}.log")]]></system-out>
</testsuite>
</testsuites>
@@ -198,18 +200,17 @@ EOF
PATH=".:$PATH"
if [ -z "$COVERAGE_DIR" ]; then
- TEST_NAME=${1#./}
+ EXE="$1"
shift
else
- TEST_NAME=${2#./}
+ EXE="$2"
fi
-if is_absolute "$TEST_NAME" ; then
- TEST_PATH="${TEST_NAME}"
+if is_absolute "$EXE"; then
+ TEST_PATH="$EXE"
else
- TEST_PATH="$(rlocation $TEST_WORKSPACE/$TEST_NAME)"
+ TEST_PATH="$(rlocation $TEST_WORKSPACE/$EXE)"
fi
-[[ -n "$RUNTEST_PRESERVE_CWD" ]] && EXE="${TEST_NAME}"
exitCode=0
signals="$(trap -l | sed -E 's/[0-9]+\)//g')"