aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/test/test-setup.sh
diff options
context:
space:
mode:
authorGravatar ulfjack <ulfjack@google.com>2018-07-27 02:37:53 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-07-27 02:39:03 -0700
commit0858ae1f6eb890c1e203a2aa21130ba34ca36a27 (patch)
tree98dd4c592049bf545ecabd6582f2a93d8d43f1d7 /tools/test/test-setup.sh
parentd0190d3503f3adb0655579312ee359c67291992d (diff)
Add a flag to split test.xml generation into a separate Spawn
At this time, this is only implemented for the StandaloneTestStrategy. This solves a race condition on Posix-like systems, where we cannot guarantee that the pipes are actually fully flushed to disk when the test process exits, and this can cause the test.xml to be empty, which makes it hard to debug issues. (The test.log files do not show up in normal CI systems, only the test.xml files.) Progress on #4608. PiperOrigin-RevId: 206292179
Diffstat (limited to 'tools/test/test-setup.sh')
-rwxr-xr-xtools/test/test-setup.sh21
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh
index d8f2a47b67..d7bb931b5f 100755
--- a/tools/test/test-setup.sh
+++ b/tools/test/test-setup.sh
@@ -152,6 +152,7 @@ if [[ -z "$no_echo" ]]; then
echo "-----------------------------------------------------------------------------"
fi
+# Unused if EXPERIMENTAL_SPLIT_XML_GENERATION is set.
function encode_output_file {
if [ -f "$1" ]; then
# Replace invalid XML characters and invalid sequence in CDATA
@@ -161,6 +162,8 @@ function encode_output_file {
fi
}
+# Unused if EXPERIMENTAL_SPLIT_XML_GENERATION is set.
+# Keep this in sync with generate-xml.sh!
function write_xml_output_file {
local duration=$(expr $(date +%s) - $start)
local errors=0
@@ -268,17 +271,27 @@ if [ "$has_tail" == true ] && [ -z "$no_echo" ]; then
wait $pid
exitCode=$?
else
- 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=$?
+ if [[ "${EXPERIMENTAL_SPLIT_XML_GENERATION}" == "1" ]]; then
+ if [ -z "$COVERAGE_DIR" ]; then
+ "${TEST_PATH}" "$@" 2>&1 || exitCode=$?
+ else
+ "$1" "$TEST_PATH" "${@:3}" 2>&1 || exitCode=$?
+ fi
else
- "$1" "$TEST_PATH" "${@:3}" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$?
+ 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=$?
+ else
+ "$1" "$TEST_PATH" "${@:3}" 2> >(tee -a "${XML_OUTPUT_FILE}.log" >&2) 1> >(tee -a "${XML_OUTPUT_FILE}.log") 2>&1 || exitCode=$?
+ fi
fi
fi
for signal in $signals; do
trap - ${signal}
done
-write_xml_output_file
+if [[ "${EXPERIMENTAL_SPLIT_XML_GENERATION}" != "1" ]]; then
+ write_xml_output_file
+fi
# Add all of the files from the undeclared outputs directory to the manifest.
if [[ -n "$TEST_UNDECLARED_OUTPUTS_DIR" && -n "$TEST_UNDECLARED_OUTPUTS_MANIFEST" ]]; then