Skip to content

Commit

Permalink
[antlir][shape] make test shape use in-tree build of bzl2ir
Browse files Browse the repository at this point in the history
Summary: Split out from D57445425 because this rebuilds the entire world.

Test Plan:
```
❯ buck2 test fbcode//antlir/bzl/tests/shapes/...
Buck UI: https://www.internalfb.com/buck2/941f3f04-989f-4abf-8669-eaf95387012f
Test UI: https://www.internalfb.com/intern/testinfra/testrun/4222124882748834
Note:    Using experimental modern dice
Network: Up: 679KiB  Down: 105MiB  (reSessionID-cd18ec0a-2f8d-471a-91f8-db42fdb10be3)
Jobs completed: 2297. Time elapsed: 11.0s.
Cache hits: 97%. Commands: 366 (cached: 354, remote: 0, local: 12)
Tests finished: Pass 24. Fail 0. Fatal 0. Skip 0. Build failure 0
```

Reviewed By: zeroxoneb

Differential Revision: D57495481

fbshipit-source-id: 17e8fd9c9df4cf1cbda666a74f468bf505ab7cf2
  • Loading branch information
vmagro authored and facebook-github-bot committed May 17, 2024
1 parent 3ab2e4d commit 5b4b82a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
11 changes: 8 additions & 3 deletions antlir/bzl/shape.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,25 @@ def _shape(__thrift = None, **fields):

return record(**fields)

def _impl(name, deps = (), visibility = None, expert_only_custom_impl = False, **kwargs): # pragma: no cover
def _impl(name, deps = (), visibility = None, expert_only_custom_impl = False, test_only_rc_bzl2_ir: bool = False, **kwargs): # pragma: no cover
if not name.endswith(".shape"):
fail("shape.impl target must be named with a .shape suffix")
export_file(
name = name + ".bzl",
)

# @oss-disable

bzl2ir = antlir_dep("bzl/shape2:bzl2ir") # @oss-enable
if test_only_rc_bzl2_ir:
bzl2ir = antlir_dep("bzl/shape2:bzl2ir")

buck_genrule(
name = name,
cmd = """
$(exe {}) {} $(location :{}.bzl) {} > $OUT
""".format(
# @oss-disable
antlir_dep("bzl/shape2:bzl2ir"), # @oss-enable
bzl2ir,
normalize_target(":" + name),
name,
shell.quote(repr({d: "$(location {})".format(d) for d in deps})),
Expand Down
1 change: 1 addition & 0 deletions antlir/bzl/tests/shapes/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ oncall("antlir")
shape.impl(
name = "test.shape",
rust_crate = "test_shape",
test_only_rc_bzl2_ir = True,
deps = [
"//antlir/bzl:target.shape",
],
Expand Down
4 changes: 2 additions & 2 deletions antlir/bzl/tests/shapes/test.shape.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

load("//antlir/bzl:shape.bzl", "shape")
load("//antlir/bzl:target.shape.bzl", "target_t")
load("@antlir//antlir/bzl:shape.bzl", "shape")
load("@antlir//antlir/bzl:target.shape.bzl", "target_t")

affiliations_t = shape.shape(
faction = str,
Expand Down

0 comments on commit 5b4b82a

Please sign in to comment.