aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-02-17 21:46:22 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-02-17 22:53:57 +0000
commit653df8813dd74042e8e084eeae238a8b9f16a3ca (patch)
tree95457f3f31e6179ae697abab81df3f3d0271881d /src/test/shell/bazel
parent8af7f68e056ce2013302a4d54c3b2a76b3130ce8 (diff)
Introduce SkylarkRepositoryModule
The SkylarkRepositoryModule declare the `repository_rule` function to Skylark to define new remote repository types (http://goo.gl/OZV3o0). The work is delagated to the `SkylarkRepositoryFunction` by the `RepositoryDelegatorFunction`. `SkylarkRepositoryContext` defines the `ctx` object passed to the `repository_rule` implementation function. This change also introduce a `SkylarkPath` and the necessary methods in `SkylarkRepositoryContext` to showcase the creation of a `local_repository` like repository. Issue #893: step 3 of the roadmap http://goo.gl/OZV3o0. -- MOS_MIGRATED_REVID=114895003
Diffstat (limited to 'src/test/shell/bazel')
-rwxr-xr-xsrc/test/shell/bazel/skylark_repository_test.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/shell/bazel/skylark_repository_test.sh b/src/test/shell/bazel/skylark_repository_test.sh
index 7b8d6338ea..c84baf42a6 100755
--- a/src/test/shell/bazel/skylark_repository_test.sh
+++ b/src/test/shell/bazel/skylark_repository_test.sh
@@ -216,6 +216,39 @@ EOF
expect_log "Tra-la!"
}
+function test_skylark_local_repository() {
+ create_new_workspace
+ repo2=$new_workspace_dir
+
+ cat > BUILD <<'EOF'
+genrule(name='bar', cmd='echo foo | tee $@', outs=['bar.txt'])
+EOF
+
+ cd ${WORKSPACE_DIR}
+ cat > WORKSPACE <<EOF
+load('/test', 'repo')
+repo(name='foo', path='$repo2')
+EOF
+
+ # Our custom repository rule
+ cat >test.bzl <<EOF
+def _impl(ctx):
+ ctx.symlink(ctx.path(ctx.attr.path), ctx.path(""))
+
+repo = repository_rule(
+ implementation=_impl,
+ local=True,
+ attrs={"path": attr.string(mandatory=True)})
+EOF
+ # Need to be in a package
+ cat > BUILD
+
+ bazel build @foo//:bar >& $TEST_log || fail "Failed to build"
+ expect_log "foo"
+ cat bazel-genfiles/external/foo/bar.txt >$TEST_log
+ expect_log "foo"
+}
+
function tear_down() {
true
}