aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules/diff_test.bzl4
-rwxr-xr-xtests/diff_test/diff_test_tests.sh26
2 files changed, 20 insertions, 10 deletions
diff --git a/rules/diff_test.bzl b/rules/diff_test.bzl
index 1ebd495..93cf363 100644
--- a/rules/diff_test.bzl
+++ b/rules/diff_test.bzl
@@ -79,8 +79,8 @@ if %ERRORLEVEL% neq 0 (
set -euo pipefail
F1="{file1}"
F2="{file2}"
-[[ "$F1" =~ external/* ]] && F1="${{F1#external/}}" || F1="$TEST_WORKSPACE/$F1"
-[[ "$F2" =~ external/* ]] && F2="${{F2#external/}}" || F2="$TEST_WORKSPACE/$F2"
+[[ "$F1" =~ ^external/* ]] && F1="${{F1#external/}}" || F1="$TEST_WORKSPACE/$F1"
+[[ "$F2" =~ ^external/* ]] && F2="${{F2#external/}}" || F2="$TEST_WORKSPACE/$F2"
if [[ -d "${{RUNFILES_DIR:-/dev/null}}" && "${{RUNFILES_MANIFEST_ONLY:-}}" != 1 ]]; then
RF1="$RUNFILES_DIR/$F1"
RF2="$RUNFILES_DIR/$F2"
diff --git a/tests/diff_test/diff_test_tests.sh b/tests/diff_test/diff_test_tests.sh
index 1cab39b..ed894c2 100755
--- a/tests/diff_test/diff_test_tests.sh
+++ b/tests/diff_test/diff_test_tests.sh
@@ -50,10 +50,12 @@ function import_diff_test() {
function assert_simple_diff_test() {
local -r flag="$1"
local -r ws="${TEST_TMPDIR}/$2"
+ local -r subdir="$3"
import_diff_test "$ws"
touch "$ws/WORKSPACE"
- cat >"$ws/BUILD" <<'eof'
+ mkdir -p "$ws/$subdir"
+ cat >"$ws/${subdir}BUILD" <<'eof'
load("//rules:diff_test.bzl", "diff_test")
diff_test(
@@ -68,17 +70,17 @@ diff_test(
file2 = "b.txt",
)
eof
- echo foo > "$ws/a.txt"
- echo bar > "$ws/b.txt"
+ echo foo > "$ws/$subdir/a.txt"
+ echo bar > "$ws/$subdir/b.txt"
(cd "$ws" && \
- bazel test "$flag" //:same --test_output=errors 1>"$TEST_log" 2>&1 \
+ bazel test "$flag" "//${subdir%/}:same" --test_output=errors 1>"$TEST_log" 2>&1 \
|| fail "expected success")
(cd "$ws" && \
- bazel test "$flag" //:different --test_output=errors 1>"$TEST_log" 2>&1 \
+ bazel test "$flag" "//${subdir%/}:different" --test_output=errors 1>"$TEST_log" 2>&1 \
&& fail "expected failure" || true)
- expect_log 'FAIL: files "a.txt" and "b.txt" differ'
+ expect_log "FAIL: files \"${subdir}a.txt\" and \"${subdir}b.txt\" differ"
}
function assert_from_ext_repo() {
@@ -187,11 +189,19 @@ eof
}
function test_simple_diff_test_with_legacy_external_runfiles() {
- assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}"
+ assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}" ""
}
function test_simple_diff_test_without_legacy_external_runfiles() {
- assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}"
+ assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}" ""
+}
+
+function test_directory_named_external_with_legacy_external_runfiles() {
+ assert_simple_diff_test "--legacy_external_runfiles" "${FUNCNAME[0]}" "path/to/direcotry/external/in/name/"
+}
+
+function test_directory_named_external_without_legacy_external_runfiles() {
+ assert_simple_diff_test "--nolegacy_external_runfiles" "${FUNCNAME[0]}" "path/to/direcotry/external/in/name/"
}
function test_from_ext_repo_with_legacy_external_runfiles() {