aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2018-08-09 05:44:19 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-09 05:45:42 -0700
commit2fe53b7b2719dd5297da062f4cfcc7bb1e745058 (patch)
treedae1bb898c4c66322a49dc9de065da0fb828cf60 /src/test
parent7b73c5f6abc9e9b574849f760873252ee987e184 (diff)
Windows,tests: port bazel_testjobs_test
//src/test/shell/integration:bazel_testjobs_test now runs on Windows. See https://github.com/bazelbuild/bazel/issues/4292 Change-Id: Ia12a01f27ee8bd5a00aead546bcaf483fc4d72a3 Closes #5835. Change-Id: I6e9af9da9221a4d4d553e8ad066b607a54c5c907 PiperOrigin-RevId: 208034351
Diffstat (limited to 'src/test')
-rw-r--r--src/test/shell/integration/BUILD8
-rwxr-xr-xsrc/test/shell/integration/bazel_testjobs_test.sh54
2 files changed, 50 insertions, 12 deletions
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index b6657b8b89..d31cd32635 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -156,9 +156,11 @@ sh_test(
sh_test(
name = "bazel_testjobs_test",
srcs = ["bazel_testjobs_test.sh"],
- data = [":test-deps"],
- shard_count = 3,
- tags = ["no_windows"],
+ data = [
+ ":test-deps",
+ "@bazel_tools//tools/bash/runfiles",
+ ],
+ shard_count = 2,
)
sh_test(
diff --git a/src/test/shell/integration/bazel_testjobs_test.sh b/src/test/shell/integration/bazel_testjobs_test.sh
index 2c6f99cd0f..59848c7f02 100755
--- a/src/test/shell/integration/bazel_testjobs_test.sh
+++ b/src/test/shell/integration/bazel_testjobs_test.sh
@@ -14,11 +14,46 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Load the test setup defined in the parent directory
-CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-source "${CURRENT_DIR}/../integration_test_setup.sh" \
+# --- begin runfiles.bash initialization ---
+# Copy-pasted from Bazel's Bash runfiles library (tools/bash/runfiles/runfiles.bash).
+set -euo pipefail
+if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ if [[ -f "$0.runfiles_manifest" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
+ elif [[ -f "$0.runfiles/MANIFEST" ]]; then
+ export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
+ elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
+case "$(uname -s | tr [:upper:] [:lower:])" in
+msys*|mingw*|cygwin*)
+ declare -r is_windows=true
+ ;;
+*)
+ declare -r is_windows=false
+ ;;
+esac
+
+if "$is_windows"; then
+ export MSYS_NO_PATHCONV=1
+ export MSYS2_ARG_CONV_EXCL="*"
+fi
+
add_to_bazelrc "test --nocache_test_results"
# End of preamble.
@@ -26,23 +61,25 @@ add_to_bazelrc "test --nocache_test_results"
function create_test_files() {
# We use this directory as a communication mechanism between test runs. Each
# test adds a unique file to the directory and then removes it.
- mkdir -p $TEST_TMPDIR/testfiles
+ local -r testfiles="$(mktemp -d "$TEST_TMPDIR/tmp.XXXXXXXX")"
- mkdir dir
+ if [[ ! -d dir ]]; then
+ mkdir dir
+ fi
cat <<EOF > dir/test.sh
#!/bin/sh
-z=\$(mktemp $TEST_TMPDIR/testfiles/tmp.XXXXXXXX)
+z=\$(mktemp "$testfiles/tmp.XXXXXXXX")
# Try to ensure other test runs have started too.
sleep 1
-numtestfiles=\$(ls -1 $TEST_TMPDIR/testfiles/ | wc -l)
+numtestfiles=\$(ls -1 "$testfiles/" | wc -l)
# The tests below are configured to prevent more than 3 tests from running at
# once. This block returns an error code from this script if it observes more
-# than 3 files in the testfiles/ directory.
+# than 3 files in the \$testfiles/ directory.
if [[ "\${numtestfiles}" -gt 3 ]] ; then
echo "Found \${numtestfiles} test files, but there should be 3 at max."
exit 1
@@ -53,7 +90,6 @@ fi
sleep 1
rm \${z}
-
EOF
chmod +x dir/test.sh