aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/BUILD3
-rw-r--r--src/test/shell/BUILD48
-rw-r--r--src/test/shell/bazel/BUILD9
-rwxr-xr-xsrc/test/shell/shell_utils_symlinks_test.sh179
-rwxr-xr-xsrc/test/shell/shell_utils_test.sh154
-rwxr-xr-xsrc/test/shell/unittest_test.sh33
-rw-r--r--tools/bash/runfiles/BUILD3
7 files changed, 295 insertions, 134 deletions
diff --git a/src/BUILD b/src/BUILD
index c539dd6806..8f5da4f0d4 100644
--- a/src/BUILD
+++ b/src/BUILD
@@ -387,8 +387,7 @@ test_suite(
"//src/test/java/com/google/devtools/common/options:all_windows_tests",
"//src/test/native:all_windows_tests",
"//src/test/py/bazel:all_windows_tests",
- "//src/test/shell/bazel:bazel_bootstrap_distfile_test",
- "//src/test/shell/bazel:bazel_windows_example_test",
+ "//src/test/shell:all_windows_tests",
"//src/tools/launcher:all_windows_tests",
"//src/tools/runfiles:all_windows_tests",
"//third_party/def_parser:all_windows_tests",
diff --git a/src/test/shell/BUILD b/src/test/shell/BUILD
index e6fa79c16a..bf86e83a82 100644
--- a/src/test/shell/BUILD
+++ b/src/test/shell/BUILD
@@ -31,6 +31,11 @@ sh_test(
name = "bashunit_test",
srcs = ["unittest_test.sh"],
data = [":bashunit"],
+ deps = [
+ # TODO(laszlocsomor): Change this to @bazel_tools//tools/bash/runfiles
+ # after Bazel is released with that target in @bazel_tools.
+ "//tools/bash/runfiles:runfiles_lib",
+ ],
)
sh_library(
@@ -47,4 +52,47 @@ sh_test(
":bashunit",
":shell_utils",
],
+ deps = [
+ # TODO(laszlocsomor): Change this to @bazel_tools//tools/bash/runfiles
+ # after Bazel is released and this target exists, and remove the
+ # visibility from //tools/bash/runfiles:runfiles_lib
+ "//tools/bash/runfiles:runfiles_lib",
+ ],
+)
+
+sh_test(
+ name = "shell_utils_symlinks_test",
+ srcs = ["shell_utils_symlinks_test.sh"],
+ data = [
+ "testenv.sh",
+ ":bashunit",
+ ":shell_utils",
+ ],
+ tags = [
+ "no_windows", # test asserts symlink behavior
+ ],
+ deps = [
+ # TODO(laszlocsomor): Change this to @bazel_tools//tools/bash/runfiles
+ # after Bazel is released and this target exists, and remove the
+ # visibility from //tools/bash/runfiles:runfiles_lib
+ "//tools/bash/runfiles:runfiles_lib",
+ ],
+)
+
+test_suite(
+ name = "windows_tests",
+ tags = [
+ "-no_windows",
+ "-slow",
+ ],
+ visibility = ["//visibility:private"],
+)
+
+test_suite(
+ name = "all_windows_tests",
+ tests = [
+ ":windows_tests",
+ "//src/test/shell/bazel:all_windows_tests",
+ ],
+ visibility = ["//src:__pkg__"],
)
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index f0dfcd49d5..5a6cda3360 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -551,3 +551,12 @@ test_suite(
name = "all_tests",
visibility = ["//visibility:public"],
)
+
+test_suite(
+ name = "all_windows_tests",
+ tests = [
+ ":bazel_bootstrap_distfile_test",
+ ":bazel_windows_example_test",
+ ],
+ visibility = ["//src/test/shell:__pkg__"],
+)
diff --git a/src/test/shell/shell_utils_symlinks_test.sh b/src/test/shell/shell_utils_symlinks_test.sh
new file mode 100755
index 0000000000..dc822ac620
--- /dev/null
+++ b/src/test/shell/shell_utils_symlinks_test.sh
@@ -0,0 +1,179 @@
+#!/bin/bash
+#
+# Copyright 2016 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This test exercises Bash utility implementations.
+
+set -euo pipefail
+# --- begin runfiles.bash initialization ---
+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/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ elif [[ -f "$TEST_SRCDIR/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$TEST_SRCDIR"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/io_bazel/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^io_bazel/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find //tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")" || { echo "Could not source unittest.bash" >&2; exit 1; }
+source "$(rlocation "io_bazel/src/test/shell/shell_utils.sh")" || { echo "Could not source shell_utils.sh" >&2; exit 1; }
+
+cd "$TEST_TMPDIR"
+
+function assert_fails_to() {
+ local -r method="$1"
+ local -r arg="${2:-}"
+ if [[ -n "$arg" ]]; then
+ "$method" "$arg" && fail "'$method' should have failed for '$arg'"
+ else
+ "$method" && fail "'$method' should have failed for empty argument"
+ fi
+ true # reset the exit status otherwise the test would be considered failed
+}
+
+function test_resolve_bad_links() {
+ local -r dir="${FUNCNAME[0]}"
+
+ mkdir -p "$dir" || fail "mkdir -p $dir"
+
+ # absolute, non-existent path
+ assert_fails_to resolve_links "$(pwd)/${dir}/non-existent"
+
+ # relative, non-existent path
+ assert_fails_to resolve_links "${dir}/non-existent"
+
+ # symlink with absolute non-existent target
+ ln -s "/non-existent" "${dir}/bad-absolute.sym"
+ assert_fails_to resolve_links "$(pwd)/${dir}/bad-absolute.sym"
+ assert_fails_to resolve_links "${dir}/bad-absolute.sym"
+
+ # symlink with relative non-existent target
+ ln -s "non-existent" "${dir}/bad-relative.sym"
+ assert_fails_to resolve_links "$(pwd)/${dir}/bad-relative.sym"
+ assert_fails_to resolve_links "${dir}/bad-relative.sym"
+
+ # circular symlink
+ ln -s "circular.sym" "${dir}/circular.sym"
+ assert_fails_to resolve_links "$(pwd)/${dir}/circular.sym"
+ assert_fails_to resolve_links "${dir}/circular.sym"
+}
+
+
+function test_resolve_symlinks() {
+ local -r dir="${FUNCNAME[0]}"
+
+ mkdir -p "${dir}/a/b" || fail "mkdir -p ${dir}/a/b"
+ echo hello > "${dir}/hello.txt"
+
+ ln -s "." "${dir}/self"
+ ln -s "../hello.txt" "${dir}/a/sym"
+ ln -s "../sym" "${dir}/a/b/sym"
+ ln -s ".././sym" "${dir}/a/b/sym-not-normalized"
+
+ assert_equals "${dir}/." "$(resolve_links "${dir}/self")"
+ assert_equals "${dir}/a/../hello.txt" "$(resolve_links "${dir}/a/sym")"
+ assert_equals "${dir}/a/b/../../hello.txt" "$(resolve_links "${dir}/a/b/sym")"
+ assert_equals \
+ "${dir}/a/b/.././../hello.txt" \
+ "$(resolve_links "${dir}/a/b/sym-not-normalized")"
+
+ cd "$dir"
+ assert_equals "./." "$(resolve_links "self")"
+ assert_equals "./." "$(resolve_links "./self")"
+ assert_equals "a/../hello.txt" "$(resolve_links "a/sym")"
+ assert_equals "a/b/../../hello.txt" "$(resolve_links "a/b/sym")"
+ assert_equals \
+ "a/b/.././../hello.txt" \
+ "$(resolve_links "a/b/sym-not-normalized")"
+
+ cd a
+ assert_equals "../." "$(resolve_links "../self")"
+ assert_equals "./../hello.txt" "$(resolve_links "sym")"
+ assert_equals "./../hello.txt" "$(resolve_links "./sym")"
+ assert_equals "b/../../hello.txt" "$(resolve_links "b/sym")"
+ assert_equals \
+ "b/.././../hello.txt" \
+ "$(resolve_links "b/sym-not-normalized")"
+
+ cd b
+ assert_equals "../../." "$(resolve_links "../../self")"
+ assert_equals "../../hello.txt" "$(resolve_links "../sym")"
+ assert_equals "./../../hello.txt" "$(resolve_links "sym")"
+ assert_equals "./../../hello.txt" "$(resolve_links "./sym")"
+ assert_equals \
+ "./.././../hello.txt" \
+ "$(resolve_links "sym-not-normalized")"
+}
+
+function test_get_realpath() {
+ local -r dir="${FUNCNAME[0]}"
+
+ mkdir -p "${dir}/a/b" || fail "mkdir -p ${dir}/a/b"
+ echo hello > "${dir}/hello.txt"
+
+ ln -s "." "${dir}/self"
+ ln -s "../hello.txt" "${dir}/a/sym"
+ ln -s "../sym" "${dir}/a/b/sym"
+ ln -s ".././sym" "${dir}/a/b/sym-not-normalized"
+
+ assert_equals "$(pwd)/${dir}" "$(get_real_path "${dir}/self")"
+ assert_equals "$(pwd)/${dir}/hello.txt" "$(get_real_path "${dir}/a/sym")"
+ assert_equals "$(pwd)/${dir}/hello.txt" "$(get_real_path "${dir}/a/b/sym")"
+ assert_equals \
+ "$(pwd)/${dir}/hello.txt" \
+ "$(get_real_path "${dir}/a/b/sym-not-normalized")"
+
+ cd "$dir"
+ local -r abs_dir=$(pwd)
+ assert_equals "${abs_dir}" "$(get_real_path "self")"
+ assert_equals "${abs_dir}" "$(get_real_path "./self")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "a/sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "a/b/sym")"
+ assert_equals \
+ "${abs_dir}/hello.txt" "$(get_real_path "a/b/sym-not-normalized")"
+
+ cd a
+ assert_equals "${abs_dir}" "$(get_real_path "../self")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "./sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "b/sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "b/sym-not-normalized")"
+
+ cd b
+ assert_equals "${abs_dir}" "$(get_real_path "../../self")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "../sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "./sym")"
+ assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym-not-normalized")"
+
+ assert_fails_to get_real_path "non-existent"
+ ln -s self self
+ assert_fails_to get_real_path "self"
+}
+
+run_suite "Tests for Bash utilities"
diff --git a/src/test/shell/shell_utils_test.sh b/src/test/shell/shell_utils_test.sh
index 7e29830fb7..daf1e8a9f6 100755
--- a/src/test/shell/shell_utils_test.sh
+++ b/src/test/shell/shell_utils_test.sh
@@ -16,20 +16,39 @@
#
# This test exercises Bash utility implementations.
-source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/unittest.bash" \
- || { echo "Could not source unittest.sh" >&2; exit 1; }
-
-source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/shell_utils.sh" \
- || { echo "shell_utils.sh not found!" >&2; exit 1; }
-
-set -eu
+set -euo pipefail
+# --- begin runfiles.bash initialization ---
+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/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ elif [[ -f "$TEST_SRCDIR/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$TEST_SRCDIR"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/io_bazel/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^io_bazel/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find //tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")" || { echo "Could not source unittest.bash" >&2; exit 1; }
+source "$(rlocation "io_bazel/src/test/shell/shell_utils.sh")" || { echo "Could not source shell_utils.sh" >&2; exit 1; }
cd "$TEST_TMPDIR"
function assert_fails_to() {
local -r method="$1"
local -r arg="${2:-}"
- if [ -n "$arg" ]; then
+ if [[ -n "$arg" ]]; then
"$method" "$arg" && fail "'$method' should have failed for '$arg'"
else
"$method" && fail "'$method' should have failed for empty argument"
@@ -37,33 +56,6 @@ function assert_fails_to() {
true # reset the exit status otherwise the test would be considered failed
}
-function test_resolve_bad_links() {
- local -r dir="${FUNCNAME[0]}"
-
- mkdir -p "$dir" || fail "mkdir -p $dir"
-
- # absolute, non-existent path
- assert_fails_to resolve_links "$(pwd)/${dir}/non-existent"
-
- # relative, non-existent path
- assert_fails_to resolve_links "${dir}/non-existent"
-
- # symlink with absolute non-existent target
- ln -s "/non-existent" "${dir}/bad-absolute.sym"
- assert_fails_to resolve_links "$(pwd)/${dir}/bad-absolute.sym"
- assert_fails_to resolve_links "${dir}/bad-absolute.sym"
-
- # symlink with relative non-existent target
- ln -s "non-existent" "${dir}/bad-relative.sym"
- assert_fails_to resolve_links "$(pwd)/${dir}/bad-relative.sym"
- assert_fails_to resolve_links "${dir}/bad-relative.sym"
-
- # circular symlink
- ln -s "circular.sym" "${dir}/circular.sym"
- assert_fails_to resolve_links "$(pwd)/${dir}/circular.sym"
- assert_fails_to resolve_links "${dir}/circular.sym"
-}
-
function test_resolve_non_links() {
local -r dir="${FUNCNAME[0]}"
@@ -84,52 +76,6 @@ function test_resolve_non_links() {
"$(pwd)/${dir}/hello.txt" "$(resolve_links "$(pwd)/${dir}/hello.txt")"
}
-function test_resolve_symlinks() {
- local -r dir="${FUNCNAME[0]}"
-
- mkdir -p "${dir}/a/b" || fail "mkdir -p ${dir}/a/b"
- echo hello > "${dir}/hello.txt"
-
- ln -s "." "${dir}/self"
- ln -s "../hello.txt" "${dir}/a/sym"
- ln -s "../sym" "${dir}/a/b/sym"
- ln -s ".././sym" "${dir}/a/b/sym-not-normalized"
-
- assert_equals "${dir}/." "$(resolve_links "${dir}/self")"
- assert_equals "${dir}/a/../hello.txt" "$(resolve_links "${dir}/a/sym")"
- assert_equals "${dir}/a/b/../../hello.txt" "$(resolve_links "${dir}/a/b/sym")"
- assert_equals \
- "${dir}/a/b/.././../hello.txt" \
- "$(resolve_links "${dir}/a/b/sym-not-normalized")"
-
- cd "$dir"
- assert_equals "./." "$(resolve_links "self")"
- assert_equals "./." "$(resolve_links "./self")"
- assert_equals "a/../hello.txt" "$(resolve_links "a/sym")"
- assert_equals "a/b/../../hello.txt" "$(resolve_links "a/b/sym")"
- assert_equals \
- "a/b/.././../hello.txt" \
- "$(resolve_links "a/b/sym-not-normalized")"
-
- cd a
- assert_equals "../." "$(resolve_links "../self")"
- assert_equals "./../hello.txt" "$(resolve_links "sym")"
- assert_equals "./../hello.txt" "$(resolve_links "./sym")"
- assert_equals "b/../../hello.txt" "$(resolve_links "b/sym")"
- assert_equals \
- "b/.././../hello.txt" \
- "$(resolve_links "b/sym-not-normalized")"
-
- cd b
- assert_equals "../../." "$(resolve_links "../../self")"
- assert_equals "../../hello.txt" "$(resolve_links "../sym")"
- assert_equals "./../../hello.txt" "$(resolve_links "sym")"
- assert_equals "./../../hello.txt" "$(resolve_links "./sym")"
- assert_equals \
- "./.././../hello.txt" \
- "$(resolve_links "sym-not-normalized")"
-}
-
function test_normalize_path() {
assert_equals "." "$(normalize_path "")"
assert_equals "." "$(normalize_path ".")"
@@ -159,52 +105,6 @@ function test_normalize_path() {
assert_equals "/blah" "$(normalize_path "/blah/./hello/../a/b/.././../.")"
}
-function test_get_realpath() {
- local -r dir="${FUNCNAME[0]}"
-
- mkdir -p "${dir}/a/b" || fail "mkdir -p ${dir}/a/b"
- echo hello > "${dir}/hello.txt"
-
- ln -s "." "${dir}/self"
- ln -s "../hello.txt" "${dir}/a/sym"
- ln -s "../sym" "${dir}/a/b/sym"
- ln -s ".././sym" "${dir}/a/b/sym-not-normalized"
-
- assert_equals "$(pwd)/${dir}" "$(get_real_path "${dir}/self")"
- assert_equals "$(pwd)/${dir}/hello.txt" "$(get_real_path "${dir}/a/sym")"
- assert_equals "$(pwd)/${dir}/hello.txt" "$(get_real_path "${dir}/a/b/sym")"
- assert_equals \
- "$(pwd)/${dir}/hello.txt" \
- "$(get_real_path "${dir}/a/b/sym-not-normalized")"
-
- cd "$dir"
- local -r abs_dir=$(pwd)
- assert_equals "${abs_dir}" "$(get_real_path "self")"
- assert_equals "${abs_dir}" "$(get_real_path "./self")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "a/sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "a/b/sym")"
- assert_equals \
- "${abs_dir}/hello.txt" "$(get_real_path "a/b/sym-not-normalized")"
-
- cd a
- assert_equals "${abs_dir}" "$(get_real_path "../self")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "./sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "b/sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "b/sym-not-normalized")"
-
- cd b
- assert_equals "${abs_dir}" "$(get_real_path "../../self")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "../sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "./sym")"
- assert_equals "${abs_dir}/hello.txt" "$(get_real_path "sym-not-normalized")"
-
- assert_fails_to get_real_path "non-existent"
- ln -s self self
- assert_fails_to get_real_path "self"
-}
-
function test_md5_sum() {
local -r dir="${FUNCNAME[0]}"
mkdir "$dir" || fail "mkdir $dir"
diff --git a/src/test/shell/unittest_test.sh b/src/test/shell/unittest_test.sh
index 638b664989..ecca241772 100755
--- a/src/test/shell/unittest_test.sh
+++ b/src/test/shell/unittest_test.sh
@@ -17,8 +17,31 @@
# - a sanity check that unittest.bash is syntactically valid
# - and a means to run some quick experiments
-DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
-source ${DIR}/unittest.bash || { echo "Could not source unittest.sh" >&2; exit 1; }
+set -euo pipefail
+# --- begin runfiles.bash initialization ---
+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/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$0.runfiles"
+ elif [[ -f "$TEST_SRCDIR/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ export RUNFILES_DIR="$TEST_SRCDIR"
+ fi
+fi
+if [[ -f "${RUNFILES_DIR:-/dev/null}/io_bazel/tools/bash/runfiles/runfiles.bash" ]]; then
+ source "${RUNFILES_DIR}/io_bazel/tools/bash/runfiles/runfiles.bash"
+elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
+ source "$(grep -m1 "^io_bazel/tools/bash/runfiles/runfiles.bash " \
+ "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
+else
+ echo >&2 "ERROR: cannot find //tools/bash/runfiles:runfiles.bash"
+ exit 1
+fi
+# --- end runfiles.bash initialization ---
+
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")" || { echo "Could not source unittest.bash" >&2; exit 1; }
function set_up() {
tmp_TEST_TMPDIR=$TEST_TMPDIR
@@ -51,7 +74,7 @@ function test_failure_message() {
cat > thing.sh <<EOF
#!/bin/bash
XML_OUTPUT_FILE=${TEST_TMPDIR}/dummy.xml
-source ${DIR}/unittest.bash
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")"
function test_thing() {
fail "I'm a failure with <>&\" escaped symbols"
@@ -72,7 +95,7 @@ function test_no_failure_message() {
cat > thing.sh <<EOF
#!/bin/bash
XML_OUTPUT_FILE=${TEST_TMPDIR}/dummy.xml
-source ${DIR}/unittest.bash
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")"
function test_thing() {
TEST_passed=blorp
@@ -91,7 +114,7 @@ function test_errexit_prints_stack_trace() {
cat > thing.sh <<EOF
#!/bin/bash
XML_OUTPUT_FILE=${TEST_TMPDIR}/dummy.xml
-source ${DIR}/unittest.bash
+source "$(rlocation "io_bazel/src/test/shell/unittest.bash")"
enable_errexit
diff --git a/tools/bash/runfiles/BUILD b/tools/bash/runfiles/BUILD
index adec4cef86..ed2d30fdb8 100644
--- a/tools/bash/runfiles/BUILD
+++ b/tools/bash/runfiles/BUILD
@@ -25,6 +25,9 @@ sh_library(
name = "runfiles_lib",
testonly = 1,
srcs = ["runfiles.bash"],
+ # TODO(laszlocsomor): remove this visibility after the tests under
+ # //src/test/shell/... depend on @bazel_tools//tools/bash/runfiles
+ visibility = ["//src/test/shell:__subpackages__"],
)
sh_test(