Parcourir la source

Replace use of deprecated `outputs` rule parameter. (#4074)

Instead compute the output in the implementation and return it via the
`DefaultInfo` provider. This matches the latest docs on how to write
rules producing a file:
https://bazel.build/rules/rules-tutorial#creating_a_file
Chandler Carruth il y a 1 an
Parent
commit
aff5b26181
1 fichiers modifiés avec 4 ajouts et 12 suppressions
  1. 4 12
      testing/file_test/rules.bzl

+ 4 - 12
testing/file_test/rules.bzl

@@ -10,14 +10,8 @@ a file which can be accessed as a list. This avoids long argument parsing.
 
 load("@rules_cc//cc:defs.bzl", "cc_test")
 
-DataFilesInfo = provider(
-    "Data files for this target.",
-    fields = {
-        "data_files": "Data files for this target",
-    },
-)
-
 def _tests_as_input_file_rule_impl(ctx):
+    out = ctx.actions.declare_file(ctx.label.name + ".txt")
     data_files = []
     for tests in ctx.attr.data:
         data_files.extend(
@@ -26,15 +20,13 @@ def _tests_as_input_file_rule_impl(ctx):
         data_files.extend(
             [f.path for f in tests[DefaultInfo].files.to_list()],
         )
-    ctx.actions.write(ctx.outputs.data_files, "\n".join(data_files) + "\n")
+    ctx.actions.write(out, "\n".join(data_files) + "\n")
+    return [DefaultInfo(files = depset([out]))]
 
 _tests_as_input_file_rule = rule(
     attrs = {
         "data": attr.label_list(allow_files = True),
     },
-    outputs = {
-        "data_files": "%{name}.txt",
-    },
     implementation = _tests_as_input_file_rule_impl,
 )
 
@@ -69,7 +61,7 @@ def file_test(
         testonly = 1,
     )
     args = ["--test_targets_file=$(rootpath :{0})".format(tests_file)] + args
-    data = [tests_file] + tests + data
+    data = [":" + tests_file] + tests + data
 
     if prebuilt_binary:
         native.sh_test(