我正在编写一些 bazel 测试,我需要能够提供某些文件的完整路径。
bazel test //webservice:checkstyle-test --test_arg="path_to_some_file"
我的问题是如何解析 bazel 测试中的输入参数?有什么类似的ctx.arg
吗?
建造
load("//:checkstyle.bzl", "checkstyle_test")
checkstyle_test(
name = ""
src = []
config = ""
)
checkstyle.bzl
def _checkstyle_test_impl(ctx):
// How can I get my input parameter here?
checkstyle_test = rule(
implementation = _checkstyle_test_impl,
test = True,
attrs = {
"_classpath": attr.label_list(default=[
Label("@com_puppycrawl_tools_checkstyle//jar")
]),
"config": attr.label(allow_single_file=True, default = "//config:checkstyle"),
"suppressions": attr.label(allow_single_file=True, default = "//config:suppressions"),
"license": attr.label(allow_single_file=True, default = "//config:license"),
"properties": attr.label(allow_single_file=True),
"opts": attr.string_list(),
"string_opts": attr.string_dict(),
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(),
},
)