-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathenumerate_tests.bzl
51 lines (45 loc) · 1.65 KB
/
enumerate_tests.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")
def _enumerate_tests_impl(ctx):
output_file = ctx.actions.declare_file(ctx.attr.name + ".ts")
input_paths = [src.path for src in ctx.files.srcs]
input_paths_file = ctx.actions.declare_file("enumerate_tests_paths")
ctx.actions.write(input_paths_file, "\n".join(input_paths))
run_node(
ctx,
executable = "enumerate_tests_bin",
inputs = ctx.files.srcs + [input_paths_file],
outputs = [output_file],
arguments = [
"-r",
ctx.attr.root_path,
"-o",
output_file.path,
input_paths_file.path,
],
)
return [DefaultInfo(files = depset([output_file]))]
enumerate_tests = rule(
implementation = _enumerate_tests_impl,
attrs = {
"enumerate_tests_bin": attr.label(
executable = True,
cfg = "exec",
default = Label("@//tools:enumerate_tests_bin"),
doc = "The script that enumerates the tests",
),
"root_path": attr.string(
default = "",
doc = "A root path to remove from srcs when importing them",
),
"srcs": attr.label_list(
mandatory = True,
allow_files = [".ts"],
doc = "Test files to enumerate (i.e. import) in the output file",
),
},
doc = """Generates a ts file that imports the given test srcs
This rule creates a test entrypoint that imports all of the individual tests
specified in 'srcs'. In tfjs-core, it is used to create 'tests.ts', which
other packages use to import the core tests all at once.
""",
)