Use a testenv.sh function rather than hardcoded list to specify the tools directories. -- MOS_MIGRATED_REVID=94645728
diff --git a/src/test/shell/bazel/test-setup.sh b/src/test/shell/bazel/test-setup.sh index 7e83685..a0fe04a 100755 --- a/src/test/shell/bazel/test-setup.sh +++ b/src/test/shell/bazel/test-setup.sh
@@ -134,16 +134,16 @@ export BAZEL_GENFILES_DIR=$(bazel info bazel-genfiles) } -# Clean-up all files that are not in tools or third_party to -# restart from a clean workspace +# Clean up all files that are not in tools directories, to restart +# from a clean workspace function cleanup_workspace() { if [ -d "${WORKSPACE_DIR:-}" ]; then echo "Cleaning up workspace" cd ${WORKSPACE_DIR} - bazel clean # Cleanup the output base + bazel clean # Clean up the output base for i in $(ls); do - if [ "$i" != '*' -a "$i" != "tools" -a "$i" != "third_party" ]; then + if ! is_tools_directory "$i"; then rm -fr "$i" fi done
diff --git a/src/test/shell/bazel/testenv.sh b/src/test/shell/bazel/testenv.sh index 3e7a9cb..4f1f3d8 100755 --- a/src/test/shell/bazel/testenv.sh +++ b/src/test/shell/bazel/testenv.sh
@@ -52,7 +52,7 @@ junit_jar="${TEST_SRCDIR}/third_party/junit/junit-*.jar" hamcrest_jar="${TEST_SRCDIR}/third_party/hamcrest/hamcrest-*.jar" -# This function copy the tools directory from Blaze. +# This function copies the tools directory from Bazel. function copy_tools_directory() { cp -R ${tools_dir}/* tools @@ -61,6 +61,18 @@ touch tools/defaults/BUILD } +# Report whether a given directory name corresponds to a tools directory. +function is_tools_directory() { + case "$1" in + tools) + true + ;; + *) + false + ;; + esac +} + # Copy the examples of the base workspace function copy_examples() { EXAMPLE="$TEST_SRCDIR/examples"