fix: copy_to_directory exposes output in runfiles (#10)

This commit is contained in:
Alex Eagle 2021-12-01 17:09:48 -08:00 committed by GitHub
parent 0d2981f288
commit 48b0a774ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -131,7 +131,10 @@ def _copy_to_directory_impl(ctx):
else:
_copy_to_dir_bash(ctx, ctx.files.srcs, output)
return [
DefaultInfo(files = depset([output])),
DefaultInfo(
files = depset([output]),
runfiles = ctx.runfiles([output]),
),
]
copy_to_directory_lib = struct(

View File

@ -129,3 +129,16 @@ diff_test(
file1 = "case_5",
file2 = ":expected_5",
)
# Case 6: directory used in a test's runfiles
copy_to_directory(
name = "case_6",
srcs = case_srcs,
)
sh_test(
name = "case_6_test",
srcs = ["case6.sh"],
data = ["case_6"],
)

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -o errexit -o nounset
cd $TEST_SRCDIR
cd $TEST_WORKSPACE
cd $(dirname $TEST_BINARY)
cd case_6
# A path that should be in the directory we have in data[]
path="f/f2/f"
if [ ! -f "$path" ]; then
echo >&2 "Expected $path to exist in runfiles"
exit 1
fi