diff options
author | 2016-02-26 10:36:35 +0000 | |
---|---|---|
committer | 2016-02-28 17:04:12 +0000 | |
commit | cff5c43c9cb9d63efe38d2e77dae4c5655a53feb (patch) | |
tree | f8afddf221fc58920c335c03ca676cd14c6e4d88 /src/test/shell/bazel | |
parent | 76139f29ca42f68f282f54531f4752d6091a831f (diff) |
Adds an executable argument to repository_ctx.file and repository_ctx.template
We sometime want to execute the created file. The executable argument
permit to control the executable bit on the created file.
Issue #893
--
MOS_MIGRATED_REVID=115653127
Diffstat (limited to 'src/test/shell/bazel')
-rwxr-xr-x | src/test/shell/bazel/skylark_repository_test.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh index 64590ae856..7d49598e2f 100755 --- a/src/test/shell/bazel/skylark_repository_test.sh +++ b/src/test/shell/bazel/skylark_repository_test.sh @@ -343,6 +343,28 @@ EOF expect_log "BOZ" } +function test_skylark_repository_executable_flag() { + setup_skylark_repository + + # Our custom repository rule + cat >test.bzl <<EOF +def _impl(ctx): + ctx.file("test.sh", "exit 0") + ctx.file("BUILD", "sh_binary(name='bar',srcs=['test.sh'])", False) + ctx.template("test2", Label("//:bar"), {}, False) + ctx.template("test2.sh", Label("//:bar"), {}, True) +repo = repository_rule(implementation=_impl, local=True) +EOF + cat >bar + + bazel run @foo//:bar >& $TEST_log || fail "Execution of @foo//:bar failed" + output_base=$(bazel info output_base) + test -x "${output_base}/external/foo/test.sh" || fail "test.sh is not executable" + test -x "${output_base}/external/foo/test2.sh" || fail "test2.sh is not executable" + test ! -x "${output_base}/external/foo/BUILD" || fail "BUILD is executable" + test ! -x "${output_base}/external/foo/test2" || fail "test2 is executable" +} + function tear_down() { true } |