diff options
author | 2017-01-26 12:55:37 +0000 | |
---|---|---|
committer | 2017-01-26 14:53:49 +0000 | |
commit | dd04adf4877963e76ac83018b46e87ad1c3095b3 (patch) | |
tree | 2513ab948e7823de5fc6b9638bb913e94c935ed7 /tools | |
parent | 96297ed7a9ab3df0f45e93bae9d71833f4195334 (diff) |
Switch Bazel to use the common test env variables.
The effect of this change on Bazel is that we now set the entire list of
env variables needed for the various protocols: sharding protocol, undeclared
outputs protocol, test warnings, unused runfiles, premature exit signalling,
and coverage. We also now set TEST_SIZE, TEST_TIMEOUT, and TEST_RANDOM_SEED.
I'm not sure if all of the Bazel-side infrastructure for those protocols is
ready yet. With further progress on code sharing, they should fall into place
soon, though.
Also set GUNIT_OUTPUT for now. Ideally, we'd change upstream to accept our
more generic names, but this should do for now.
--
PiperOrigin-RevId: 145660945
MOS_MIGRATED_REVID=145660945
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test/test-setup.sh | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/tools/test/test-setup.sh b/tools/test/test-setup.sh index 47666d688f..f43c1e6cad 100755 --- a/tools/test/test-setup.sh +++ b/tools/test/test-setup.sh @@ -27,25 +27,57 @@ else echo 'exec ${PAGER:-/usr/bin/less} "$0" || exit 1' fi -# Bazel sets some environment vars to relative paths, but it's easier to deal -# with absolute paths once we're actually running the test, so let's convert -# them. -if [[ "$TEST_SRCDIR" != /* ]]; then - export TEST_SRCDIR="$PWD/$TEST_SRCDIR" -fi -if [[ "$JAVA_RUNFILES" != /* ]]; then - export JAVA_RUNFILES="$PWD/$JAVA_RUNFILES" -fi -if [[ "$PYTHON_RUNFILES" != /* ]]; then - export PYTHON_RUNFILES="$PWD/$PYTHON_RUNFILES" -fi -if [[ "$TEST_TMPDIR" != /* ]]; then - export TEST_TMPDIR="$PWD/$TEST_TMPDIR" -fi -if [[ "$XML_OUTPUT_FILE" != /* ]]; then - export XML_OUTPUT_FILE="$PWD/$XML_OUTPUT_FILE" +# Bazel sets some environment vars to relative paths to improve caching and +# support remote execution, where the absolute path may not be known to Bazel. +# Convert them to absolute paths here before running the actual test. +[[ "$TEST_PREMATURE_EXIT_FILE" != /* ]] && + TEST_PREMATURE_EXIT_FILE="$PWD/$TEST_PREMATURE_EXIT_FILE" +[[ "$TEST_WARNINGS_OUTPUT_FILE" != /* ]] && + TEST_WARNINGS_OUTPUT_FILE="$PWD/$TEST_WARNINGS_OUTPUT_FILE" +[[ "$TEST_LOGSPLITTER_OUTPUT_FILE" != /* ]] && + TEST_LOGSPLITTER_OUTPUT_FILE="$PWD/$TEST_LOGSPLITTER_OUTPUT_FILE" +[[ "$TEST_INFRASTRUCTURE_FAILURE_FILE" != /* ]] && + TEST_INFRASTRUCTURE_FAILURE_FILE="$PWD/$TEST_INFRASTRUCTURE_FAILURE_FILE" +[[ "$TEST_UNUSED_RUNFILES_LOG_FILE" != /* ]] && + TEST_UNUSED_RUNFILES_LOG_FILE="$PWD/$TEST_UNUSED_RUNFILES_LOG_FILE" +[[ "$TEST_UNDECLARED_OUTPUTS_DIR" != /* ]] && + TEST_UNDECLARED_OUTPUTS_DIR="$PWD/$TEST_UNDECLARED_OUTPUTS_DIR" +[[ "$TEST_UNDECLARED_OUTPUTS_MANIFEST" != /* ]] && + TEST_UNDECLARED_OUTPUTS_MANIFEST="$PWD/$TEST_UNDECLARED_OUTPUTS_MANIFEST" +[[ "$TEST_UNDECLARED_OUTPUTS_ZIP" != /* ]] && + TEST_UNDECLARED_OUTPUTS_ZIP="$PWD/$TEST_UNDECLARED_OUTPUTS_ZIP" +[[ "$TEST_UNDECLARED_OUTPUTS_ANNOTATIONS" != /* ]] && + TEST_UNDECLARED_OUTPUTS_ANNOTATIONS="$PWD/$TEST_UNDECLARED_OUTPUTS_ANNOTATIONS" +[[ "$TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR" != /* ]] && + TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR="$PWD/$TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR" + +[[ "$TEST_SRCDIR" != /* ]] && TEST_SRCDIR="$PWD/$TEST_SRCDIR" +[[ "$TEST_TMPDIR" != /* ]] && TEST_TMPDIR="$PWD/$TEST_TMPDIR" +[[ "$XML_OUTPUT_FILE" != /* ]] && XML_OUTPUT_FILE="$PWD/$XML_OUTPUT_FILE" + +# The test shard status file is only set for sharded tests. +if [[ -n "$TEST_SHARD_STATUS_FILE" ]]; then + [[ "$TEST_SHARD_STATUS_FILE" != /* ]] && TEST_SHARD_STATUS_FILE="$PWD/$TEST_SHARD_STATUS_FILE" + mkdir -p "${TEST_SHARD_STATUS_FILE%/*}" fi +[[ "$RUNFILES_DIR" != /* ]] && RUNFILES_DIR="$PWD/$RUNFILES_DIR" + +# TODO(ulfjack): Standardize on RUNFILES_DIR and remove the {JAVA,PYTHON}_RUNFILES vars. +[[ "$JAVA_RUNFILES" != /* ]] && JAVA_RUNFILES="$PWD/$JAVA_RUNFILES" +[[ "$PYTHON_RUNFILES" != /* ]] && PYTHON_RUNFILES="$PWD/$PYTHON_RUNFILES" + +# Create directories for undeclared outputs and their annotations +mkdir -p "${XML_OUTPUT_FILE%/*}" \ + "$TEST_UNDECLARED_OUTPUTS_DIR" \ + "$TEST_UNDECLARED_OUTPUTS_ANNOTATIONS_DIR" + +# Unexport environment variables related to undeclared test outputs that are +# only supposed to be used in this script. +export -n TEST_UNDECLARED_OUTPUTS_MANIFEST +export -n TEST_UNDECLARED_OUTPUTS_ZIP +export -n TEST_UNDECLARED_OUTPUTS_ANNOTATIONS + # Tell googletest about Bazel sharding. if [[ -n "${TEST_TOTAL_SHARDS+x}" ]] && ((TEST_TOTAL_SHARDS != 0)); then export GTEST_SHARD_INDEX="${TEST_SHARD_INDEX}" @@ -53,6 +85,10 @@ if [[ -n "${TEST_TOTAL_SHARDS+x}" ]] && ((TEST_TOTAL_SHARDS != 0)); then fi export GTEST_TMP_DIR="${TEST_TMPDIR}" +# TODO(ulfjack): Update Gunit to accept XML_OUTPUT_FILE and drop this env +# variable. +GUNIT_OUTPUT="xml:${XML_OUTPUT_FILE}" + RUNFILES_MANIFEST_FILE="${TEST_SRCDIR}/MANIFEST" if [ -z "$RUNFILES_MANIFEST_ONLY" ]; then |