""" Generate warehouse test layout inside bazel to be compared to the layout currently checked in. """ def _test_layout_impl(ctx): out = ctx.actions.declare_directory(ctx.label.name) args = ctx.actions.args() args.add(ctx.executable.lift.path) args.add(out.path) args.add(ctx.attr.warehouse_path) ctx.actions.run( arguments = [args], inputs = ctx.files.srcs, outputs = [out], tools = [ctx.executable.lift], executable = ctx.executable.layout_tool, ) return [DefaultInfo(files = depset([out]))] test_layout = rule( implementation = _test_layout_impl, attrs = { "layout_tool": attr.label( default = Label("//test/fixtures:generate_warehouse_layout"), executable = True, cfg = "exec", allow_files = True, doc = "points to sh_binary that generates the layout", ), "lift": attr.label( default = Label("//cmd/f8n/warehouse/lift"), executable = True, cfg = "exec", allow_files = True, ), "warehouse_path": attr.string( mandatory = True, ), "srcs": attr.label_list( allow_files = True, allow_empty = False, ), }, )