diff options
author | Benjamin Peterson <bp@benjamin.pe> | 2017-06-28 14:24:03 +0200 |
---|---|---|
committer | Marcel Hlopko <hlopko@google.com> | 2017-06-28 15:27:29 +0200 |
commit | 218c36341b2911002164c6ccac9decf4fed9e380 (patch) | |
tree | efa93bb1a2788e3884f0be821084828636bcb311 /tools/test | |
parent | 224a0da597ddae822a0a9b2ae314a25fa6481bfe (diff) |
Ensure shards of the same test have unique names in the fallback xml
test-setup.sh currently uses the test target name as the "name"
attribute in the xml output's "testcase" element. This ensures names
in the xml are unique across the workspace for unsharded
tests. However, sharded tests all end up with the same "name"
attribute. This angers some junitxml processing tools, which can be
quite persnickity about uniqueness. Let's generate unique test names
of the form "mytest_shard_N/M" for sharded tests.
Change-Id: I6ea82f56846b88449da977dc6629a73b695a485e
PiperOrigin-RevId: 160397341
Diffstat (limited to 'tools/test')
-rwxr-xr-x | tools/test/test-setup.sh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh index 8ce2ea8dce..058c459cc1 100755 --- a/tools/test/test-setup.sh +++ b/tools/test/test-setup.sh @@ -179,6 +179,11 @@ if [ -n "${XML_OUTPUT_FILE-}" -a ! -f "${XML_OUTPUT_FILE-}" ]; then 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> |