Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set PATH_PREFIX=./ instead of failing to bazel run a program with a perl_binary data dep #65

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions perl/binary_wrapper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ elif [ -s `dirname $0`/../../MANIFEST ]; then
elif [ -d $0.runfiles ]; then
PATH_PREFIX=`cd $0.runfiles; pwd`/{workspace_name}/
else
echo "WARNING: it does not look to be at the .runfiles directory" >&2
exit 1
PATH_PREFIX=./
fi

{env_vars} $PATH_PREFIX{interpreter} -I${PATH_PREFIX} ${PATH_PREFIX}{main} "$@"
35 changes: 35 additions & 0 deletions test/data_dep/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
genrule(
name = "gen_program_sh",
srcs = ["@genhtml//:genhtml_bin"],
outs = ["program.sh"],
cmd = """\
cat <<"EOF" >$@
#!/bin/bash
set -euxo pipefail
genhtml='$(rootpath @genhtml//:genhtml_bin)'
test "$$("$$genhtml" --version)" == "genhtml: LCOV version 1.0"
EOF
""",
)

sh_binary(
name = "program_bin",
srcs = ["program.sh"],
data = ["@genhtml//:genhtml_bin"],
)

genrule(
name = "gen_program_test_sh",
srcs = [":program_bin"],
outs = ["program_test.sh"],
cmd = """\
echo '#!/bin/sh' >$@
echo 'exec env --ignore-environment test/data_dep/program_bin' >>$@
""",
)

sh_test(
name = "program_test",
srcs = ["program_test.sh"],
data = [":program_bin"],
)