From aff5b26181d3a5f9e976d65b09a993107f03bc8d Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 22 Jun 2024 05:11:18 +0200 Subject: [PATCH] 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 --- testing/file_test/rules.bzl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/testing/file_test/rules.bzl b/testing/file_test/rules.bzl index cc8b2334c587..116d0bf3ad8a 100644 --- a/testing/file_test/rules.bzl +++ b/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(