Skip to content

Commit 0a2c4ed

Browse files
fmeumcopybara-github
authored andcommitted
Fix corner cases in Bash runfiles library
Due to tests not actually verifying the exit code of rlocation calls, a few special cases were not handled correctly. In particular, absolute paths still went through regular rlocation lookup and could fail there even after the absolute path had been printed to stdout. Also adds a missing newline in the (very rare) case that a manifest entry is found, but doesn't point to an existing file (e.g. if it is an unresolved symlink), and `rlocation` is not used with command substitution, but some other mechanism that doesn't strip trailing newlines. The tests now assert the expected exit code (== 0 or != 0). Fixes bazelbuild#16933 Closes bazelbuild#16945. PiperOrigin-RevId: 494609104 Change-Id: I30333219176a61bda51f08c2c6bc927ce653d681
1 parent 09da33b commit 0a2c4ed

File tree

2 files changed

+98
-81
lines changed

2 files changed

+98
-81
lines changed

tools/bash/runfiles/runfiles.bash

+13-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ function rlocation() {
126126
fi
127127
# If the path is absolute, print it as-is.
128128
echo "$1"
129+
return 0
129130
elif [[ "$1" == ../* || "$1" == */.. || "$1" == ./* || "$1" == */./* || "$1" == "*/." || "$1" == *//* ]]; then
130131
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
131132
echo >&2 "ERROR[runfiles.bash]: rlocation($1): path is not normalized"
@@ -234,7 +235,7 @@ function runfiles_current_repository() {
234235
rlocation_path=$(__runfiles_maybe_grep -m1 "^[^ ]* ${escaped_caller_path}$" "${RUNFILES_MANIFEST_FILE}" | cut -d ' ' -f 1)
235236
if [[ -z "$rlocation_path" ]]; then
236237
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
237-
echo >&2 "INFO[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) is not the target of an entry in the runfiles manifest ($RUNFILES_MANIFEST_FILE)"
238+
echo >&2 "ERROR[runfiles.bash]: runfiles_current_repository($idx): ($normalized_caller_path) is not the target of an entry in the runfiles manifest ($RUNFILES_MANIFEST_FILE)"
238239
fi
239240
return 1
240241
else
@@ -302,6 +303,9 @@ function runfiles_current_repository() {
302303
export -f runfiles_current_repository
303304

304305
function runfiles_rlocation_checked() {
306+
# FIXME: If the runfiles lookup fails, the exit code of this function is 0 if
307+
# and only if the runfiles manifest exists. In particular, the exit code
308+
# behavior is not consistent across platforms.
305309
if [[ -e "${RUNFILES_DIR:-/dev/null}/$1" ]]; then
306310
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
307311
echo >&2 "INFO[runfiles.bash]: rlocation($1): found under RUNFILES_DIR ($RUNFILES_DIR), return"
@@ -344,6 +348,9 @@ function runfiles_rlocation_checked() {
344348
# existence and would have returned the non-existent path. It seems
345349
# better to return no path rather than a potentially different,
346350
# non-empty path.
351+
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
352+
echo >&2 "INFO[runfiles.bash]: rlocation($1): found in manifest as ($candidate) via prefix ($prefix), but file does not exist"
353+
fi
347354
break
348355
done
349356
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
@@ -356,6 +363,11 @@ function runfiles_rlocation_checked() {
356363
echo >&2 "INFO[runfiles.bash]: rlocation($1): found in manifest as ($result)"
357364
fi
358365
echo "$result"
366+
else
367+
if [[ "${RUNFILES_LIB_DEBUG:-}" == 1 ]]; then
368+
echo >&2 "INFO[runfiles.bash]: rlocation($1): found in manifest as ($result), but file does not exist"
369+
fi
370+
echo ""
359371
fi
360372
fi
361373
else

tools/bash/runfiles/runfiles_test.bash

+85-80
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ function test_rlocation_abs_path() {
126126
source "$runfiles_lib_path"
127127

128128
if is_windows; then
129-
[[ "$(rlocation "c:/Foo")" == "c:/Foo" ]] || fail
130-
[[ "$(rlocation "c:\\Foo")" == "c:\\Foo" ]] || fail
129+
[[ "$(rlocation "c:/Foo" || echo failed)" == "c:/Foo" ]] || fail
130+
[[ "$(rlocation "c:\\Foo" || echo failed)" == "c:\\Foo" ]] || fail
131131
else
132-
[[ "$(rlocation "/Foo")" == "/Foo" ]] || fail
132+
[[ "$(rlocation "/Foo" || echo failed)" == "/Foo" ]] || fail
133133
fi
134134
}
135135

@@ -140,35 +140,40 @@ a/b $tmpdir/c/d
140140
e/f $tmpdir/g h
141141
y $tmpdir/y
142142
c/dir $tmpdir/dir
143+
unresolved $tmpdir/unresolved
143144
EOF
144145
mkdir "${tmpdir}/c"
145146
mkdir "${tmpdir}/y"
146147
mkdir -p "${tmpdir}/dir/deeply/nested"
147148
touch "${tmpdir}/c/d" "${tmpdir}/g h"
148149
touch "${tmpdir}/dir/file"
150+
ln -s /does/not/exist "${tmpdir}/dir/unresolved"
149151
touch "${tmpdir}/dir/deeply/nested/file"
152+
ln -s /does/not/exist "${tmpdir}/unresolved"
150153

151154
export RUNFILES_DIR=
152155
export RUNFILES_MANIFEST_FILE=$tmpdir/foo.runfiles_manifest
153156
source "$runfiles_lib_path"
154157

155-
[[ -z "$(rlocation a)" ]] || fail
156-
[[ -z "$(rlocation c/d)" ]] || fail
157-
[[ "$(rlocation a/b)" == "$tmpdir/c/d" ]] || fail
158-
[[ "$(rlocation e/f)" == "$tmpdir/g h" ]] || fail
159-
[[ "$(rlocation y)" == "$tmpdir/y" ]] || fail
160-
[[ "$(rlocation c)" == "" ]] || fail
161-
[[ "$(rlocation c/di)" == "" ]] || fail
162-
[[ "$(rlocation c/dir)" == "$tmpdir/dir" ]] || fail
163-
[[ "$(rlocation c/dir/file)" == "$tmpdir/dir/file" ]] || fail
164-
[[ "$(rlocation c/dir/deeply/nested/file)" == "$tmpdir/dir/deeply/nested/file" ]] || fail
165-
rm -r "$tmpdir/c/d" "$tmpdir/g h" "$tmpdir/y" "$tmpdir/dir"
166-
[[ -z "$(rlocation a/b)" ]] || fail
167-
[[ -z "$(rlocation e/f)" ]] || fail
168-
[[ -z "$(rlocation y)" ]] || fail
169-
[[ -z "$(rlocation c/dir)" ]] || fail
170-
[[ -z "$(rlocation c/dir/file)" ]] || fail
171-
[[ -z "$(rlocation c/dir/deeply/nested/file)" ]] || fail
158+
[[ -z "$(rlocation a || echo failed)" ]] || fail
159+
[[ -z "$(rlocation c/d || echo failed)" ]] || fail
160+
[[ "$(rlocation a/b || echo failed)" == "$tmpdir/c/d" ]] || fail
161+
[[ "$(rlocation e/f || echo failed)" == "$tmpdir/g h" ]] || fail
162+
[[ "$(rlocation y || echo failed)" == "$tmpdir/y" ]] || fail
163+
[[ -z "$(rlocation c || echo failed)" ]] || fail
164+
[[ -z "$(rlocation c/di || echo failed)" ]] || fail
165+
[[ "$(rlocation c/dir || echo failed)" == "$tmpdir/dir" ]] || fail
166+
[[ "$(rlocation c/dir/file || echo failed)" == "$tmpdir/dir/file" ]] || fail
167+
[[ -z "$(rlocation c/dir/unresolved || echo failed)" ]] || fail
168+
[[ "$(rlocation c/dir/deeply/nested/file || echo failed)" == "$tmpdir/dir/deeply/nested/file" ]] || fail
169+
[[ -z "$(rlocation unresolved || echo failed)" ]] || fail
170+
rm -r "$tmpdir/c/d" "$tmpdir/g h" "$tmpdir/y" "$tmpdir/dir" "$tmpdir/unresolved"
171+
[[ -z "$(rlocation a/b || echo failed)" ]] || fail
172+
[[ -z "$(rlocation e/f || echo failed)" ]] || fail
173+
[[ -z "$(rlocation y || echo failed)" ]] || fail
174+
[[ -z "$(rlocation c/dir || echo failed)" ]] || fail
175+
[[ -z "$(rlocation c/dir/file || echo failed)" ]] || fail
176+
[[ -z "$(rlocation c/dir/deeply/nested/file || echo failed)" ]] || fail
172177
}
173178

174179
function test_manifest_based_envvars() {
@@ -194,15 +199,15 @@ function test_init_directory_based_runfiles() {
194199

195200
mkdir -p "$RUNFILES_DIR/a"
196201
touch "$RUNFILES_DIR/a/b" "$RUNFILES_DIR/c d"
197-
[[ "$(rlocation a)" == "$RUNFILES_DIR/a" ]] || fail
198-
[[ -z "$(rlocation c/d)" ]] || fail
199-
[[ "$(rlocation a/b)" == "$RUNFILES_DIR/a/b" ]] || fail
200-
[[ "$(rlocation "c d")" == "$RUNFILES_DIR/c d" ]] || fail
201-
[[ -z "$(rlocation "c")" ]] || fail
202+
[[ "$(rlocation a || echo failed)" == "$RUNFILES_DIR/a" ]] || fail
203+
[[ "$(rlocation c/d || echo failed)" == failed ]] || fail
204+
[[ "$(rlocation a/b || echo failed)" == "$RUNFILES_DIR/a/b" ]] || fail
205+
[[ "$(rlocation "c d" || echo failed)" == "$RUNFILES_DIR/c d" ]] || fail
206+
[[ "$(rlocation "c" || echo failed)" == failed ]] || fail
202207
rm -r "$RUNFILES_DIR/a" "$RUNFILES_DIR/c d"
203-
[[ -z "$(rlocation a)" ]] || fail
204-
[[ -z "$(rlocation a/b)" ]] || fail
205-
[[ -z "$(rlocation "c d")" ]] || fail
208+
[[ "$(rlocation a || echo failed)" == failed ]] || fail
209+
[[ "$(rlocation a/b || echo failed)" == failed ]] || fail
210+
[[ "$(rlocation "c d" || echo failed)" == failed ]] || fail
206211
}
207212

208213
function test_directory_based_runfiles_with_repo_mapping_from_main() {
@@ -228,23 +233,23 @@ EOF
228233
touch "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile"
229234
touch "$RUNFILES_DIR/config.json"
230235

231-
[[ "$(rlocation "my_module/bar/runfile" "")" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
232-
[[ "$(rlocation "my_workspace/bar/runfile" "")" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
233-
[[ "$(rlocation "my_protobuf/foo/runfile" "")" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
234-
[[ "$(rlocation "my_protobuf/bar/dir" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
235-
[[ "$(rlocation "my_protobuf/bar/dir/file" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
236-
[[ "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
236+
[[ "$(rlocation "my_module/bar/runfile" "" || echo failed)" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
237+
[[ "$(rlocation "my_workspace/bar/runfile" "" || echo failed)" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
238+
[[ "$(rlocation "my_protobuf/foo/runfile" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
239+
[[ "$(rlocation "my_protobuf/bar/dir" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
240+
[[ "$(rlocation "my_protobuf/bar/dir/file" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
241+
[[ "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
237242

238-
[[ -z "$(rlocation "protobuf/foo/runfile" "")" ]] || fail
239-
[[ -z "$(rlocation "protobuf/bar/dir/dir/de eply/nes ted/fi~le" "")" ]] || fail
243+
[[ "$(rlocation "protobuf/foo/runfile" "" || echo failed)" == failed ]] || fail
244+
[[ "$(rlocation "protobuf/bar/dir/dir/de eply/nes ted/fi~le" "" || echo failed)" == failed ]] || fail
240245

241-
[[ "$(rlocation "_main/bar/runfile" "")" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
242-
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "")" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
243-
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
244-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
245-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
246+
[[ "$(rlocation "_main/bar/runfile" "" || echo failed)" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
247+
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
248+
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
249+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
250+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
246251

247-
[[ "$(rlocation "config.json" "")" == "$RUNFILES_DIR/config.json" ]] || fail
252+
[[ "$(rlocation "config.json" "" || echo failed)" == "$RUNFILES_DIR/config.json" ]] || fail
248253
}
249254

250255
function test_directory_based_runfiles_with_repo_mapping_from_other_repo() {
@@ -270,21 +275,21 @@ EOF
270275
touch "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile"
271276
touch "$RUNFILES_DIR/config.json"
272277

273-
[[ "$(rlocation "protobuf/foo/runfile" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
274-
[[ "$(rlocation "protobuf/bar/dir" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
275-
[[ "$(rlocation "protobuf/bar/dir/file" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
276-
[[ "$(rlocation "protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
278+
[[ "$(rlocation "protobuf/foo/runfile" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
279+
[[ "$(rlocation "protobuf/bar/dir" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
280+
[[ "$(rlocation "protobuf/bar/dir/file" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
281+
[[ "$(rlocation "protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
277282

278-
[[ -z "$(rlocation "my_module/bar/runfile" "protobuf~3.19.2")" ]] || fail
279-
[[ -z "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" ]] || fail
283+
[[ "$(rlocation "my_module/bar/runfile" "protobuf~3.19.2" || echo failed)" == failed ]] || fail
284+
[[ "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" == failed ]] || fail
280285

281-
[[ "$(rlocation "_main/bar/runfile" "protobuf~3.19.2")" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
282-
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
283-
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
284-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
285-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
286+
[[ "$(rlocation "_main/bar/runfile" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/_main/bar/runfile" ]] || fail
287+
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/foo/runfile" ]] || fail
288+
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir" ]] || fail
289+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/file" ]] || fail
290+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
286291

287-
[[ "$(rlocation "config.json" "protobuf~3.19.2")" == "$RUNFILES_DIR/config.json" ]] || fail
292+
[[ "$(rlocation "config.json" "protobuf~3.19.2" || echo failed)" == "$RUNFILES_DIR/config.json" ]] || fail
288293
}
289294

290295
function test_manifest_based_runfiles_with_repo_mapping_from_main() {
@@ -316,23 +321,23 @@ EOF
316321
touch "$tmpdir/protobuf~3.19.2/foo/runfile"
317322
touch "$tmpdir/config.json"
318323

319-
[[ "$(rlocation "my_module/bar/runfile" "")" == "$tmpdir/_main/bar/runfile" ]] || fail
320-
[[ "$(rlocation "my_workspace/bar/runfile" "")" == "$tmpdir/_main/bar/runfile" ]] || fail
321-
[[ "$(rlocation "my_protobuf/foo/runfile" "")" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
322-
[[ "$(rlocation "my_protobuf/bar/dir" "")" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
323-
[[ "$(rlocation "my_protobuf/bar/dir/file" "")" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
324-
[[ "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "")" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
324+
[[ "$(rlocation "my_module/bar/runfile" "" || echo failed)" == "$tmpdir/_main/bar/runfile" ]] || fail
325+
[[ "$(rlocation "my_workspace/bar/runfile" "" || echo failed)" == "$tmpdir/_main/bar/runfile" ]] || fail
326+
[[ "$(rlocation "my_protobuf/foo/runfile" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
327+
[[ "$(rlocation "my_protobuf/bar/dir" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
328+
[[ "$(rlocation "my_protobuf/bar/dir/file" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
329+
[[ "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
325330

326-
[[ -z "$(rlocation "protobuf/foo/runfile" "")" ]] || fail
327-
[[ -z "$(rlocation "protobuf/bar/dir/dir/de eply/nes ted/fi~le" "")" ]] || fail
331+
[[ -z "$(rlocation "protobuf/foo/runfile" "" || echo failed)" ]] || fail
332+
[[ -z "$(rlocation "protobuf/bar/dir/dir/de eply/nes ted/fi~le" "" || echo failed)" ]] || fail
328333

329-
[[ "$(rlocation "_main/bar/runfile" "")" == "$tmpdir/_main/bar/runfile" ]] || fail
330-
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "")" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
331-
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "")" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
332-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "")" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
333-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "")" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
334+
[[ "$(rlocation "_main/bar/runfile" "" || echo failed)" == "$tmpdir/_main/bar/runfile" ]] || fail
335+
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
336+
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
337+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
338+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
334339

335-
[[ "$(rlocation "config.json" "")" == "$tmpdir/config.json" ]] || fail
340+
[[ "$(rlocation "config.json" "" || echo failed)" == "$tmpdir/config.json" ]] || fail
336341
}
337342

338343
function test_manifest_based_runfiles_with_repo_mapping_from_other_repo() {
@@ -364,21 +369,21 @@ EOF
364369
touch "$tmpdir/protobuf~3.19.2/foo/runfile"
365370
touch "$tmpdir/config.json"
366371

367-
[[ "$(rlocation "protobuf/foo/runfile" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
368-
[[ "$(rlocation "protobuf/bar/dir" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
369-
[[ "$(rlocation "protobuf/bar/dir/file" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
370-
[[ "$(rlocation "protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
372+
[[ "$(rlocation "protobuf/foo/runfile" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
373+
[[ "$(rlocation "protobuf/bar/dir" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
374+
[[ "$(rlocation "protobuf/bar/dir/file" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
375+
[[ "$(rlocation "protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
371376

372-
[[ -z "$(rlocation "my_module/bar/runfile" "protobuf~3.19.2")" ]] || fail
373-
[[ -z "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" ]] || fail
377+
[[ -z "$(rlocation "my_module/bar/runfile" "protobuf~3.19.2" || echo failed)" ]] || fail
378+
[[ -z "$(rlocation "my_protobuf/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" ]] || fail
374379

375-
[[ "$(rlocation "_main/bar/runfile" "protobuf~3.19.2")" == "$tmpdir/_main/bar/runfile" ]] || fail
376-
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
377-
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
378-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
379-
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2")" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
380+
[[ "$(rlocation "_main/bar/runfile" "protobuf~3.19.2" || echo failed)" == "$tmpdir/_main/bar/runfile" ]] || fail
381+
[[ "$(rlocation "protobuf~3.19.2/foo/runfile" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/foo/runfile" ]] || fail
382+
[[ "$(rlocation "protobuf~3.19.2/bar/dir" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir" ]] || fail
383+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/file" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/file" ]] || fail
384+
[[ "$(rlocation "protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" "protobuf~3.19.2" || echo failed)" == "$tmpdir/protobuf~3.19.2/bar/dir/de eply/nes ted/fi~le" ]] || fail
380385

381-
[[ "$(rlocation "config.json" "protobuf~3.19.2")" == "$tmpdir/config.json" ]] || fail
386+
[[ "$(rlocation "config.json" "protobuf~3.19.2" || echo failed)" == "$tmpdir/config.json" ]] || fail
382387
}
383388

384389
function test_directory_based_envvars() {

0 commit comments

Comments
 (0)