diff options
author | 2018-07-06 05:52:08 -0700 | |
---|---|---|
committer | 2018-07-06 05:53:45 -0700 | |
commit | da280efa4335ea9bb2581172aa695d6316d1f16d (patch) | |
tree | 2bfbdbda0befd9b99db218cc4d1f209ab8b49ac8 /src/test | |
parent | 0feb714ba783f9e0b326575c0f6372eeafd7baab (diff) |
Make skylark repository functions exportable
In this way, their name is one they can actually be referred to by.
This is necessary, as Skylark repository rules end up in the resolved
file when freezing the versions of external dependencies---and the call
to the repository function might be indirect.
Change-Id: Ie1b5a28fac4f690c424de848b42d0c4a217d494d
PiperOrigin-RevId: 203466286
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/shell/bazel/workspace_resolved_test.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/shell/bazel/workspace_resolved_test.sh b/src/test/shell/bazel/workspace_resolved_test.sh index cc9d9ec6d8..b013c6dcaf 100755 --- a/src/test/shell/bazel/workspace_resolved_test.sh +++ b/src/test/shell/bazel/workspace_resolved_test.sh @@ -388,4 +388,51 @@ EOF expect_log "Failure-message" } +test_indirect_call() { + rm -rf fetchrepo + mkdir fetchrepo + cd fetchrepo + touch BUILD + cat > rule.bzl <<'EOF' +def _trivial_rule_impl(ctx): + ctx.file("BUILD","genrule(name='hello', outs=['hello.txt'], cmd=' echo hello world > $@')") + +trivial_rule = repository_rule( + implementation = _trivial_rule_impl, + attrs = {}, +) +EOF + cat > indirect.bzl <<'EOF' +def call(fn_name, **args): + fn_name(**args) +EOF + cat > WORKSPACE <<'EOF' +load("//:rule.bzl", "trivial_rule") +load("//:indirect.bzl", "call") + +call(trivial_rule, name="foo") +EOF + bazel sync --experimental_repository_resolved_file=../repo.bzl + bazel shutdown; sync; sleep 10 + + cd .. + echo; cat repo.bzl; echo + touch WORKSPACE + cat > BUILD <<'EOF' +load("//:repo.bzl", "resolved") + +ruleclass = "".join([entry["original_rule_class"] for entry in resolved if entry["original_attributes"]["name"]=="foo"]) + +genrule( + name = "ruleclass", + outs = ["ruleclass.txt"], + cmd = "echo %s > $@" % (ruleclass,) +) +EOF + bazel build //:ruleclass + cat `bazel info bazel-genfiles`/ruleclass.txt > ${TEST_log} + expect_log '//:rule.bzl%trivial_rule' + expect_not_log 'fn_name' +} + run_suite "workspace_resolved_test tests" |