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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
load("//cc/toolchains:format.bzl", "format_arg")
load("//cc/toolchains:nested_args.bzl", "cc_nested_args")
load("//cc/toolchains/impl:variables.bzl", "cc_builtin_variables", "cc_variable", "types")
load("//tests/rule_based_toolchain:analysis_test_suite.bzl", "analysis_test_suite")
load(":variables_test.bzl", "TARGETS", "TESTS")
cc_variable(
name = "str",
type = types.string,
)
cc_variable(
name = "optional_list",
type = types.option(types.list(types.string)),
)
cc_variable(
name = "str_list",
type = types.list(types.string),
)
cc_variable(
name = "str_option",
type = types.option(types.string),
)
cc_variable(
name = "struct",
actions = ["//tests/rule_based_toolchain/actions:c_compile"],
type = types.struct(
nested_str = types.string,
nested_str_list = types.list(types.string),
),
)
cc_variable(
name = "struct_list",
actions = ["//tests/rule_based_toolchain/actions:c_compile"],
type = types.list(types.struct(
nested_str = types.string,
nested_str_list = types.list(types.string),
)),
)
cc_variable(
name = "struct_list.nested_str_list",
type = types.unknown,
)
# Dots in the name confuse the test rules.
# It would end up generating targets.struct_list.nested_str_list.
alias(
name = "nested_str_list",
actual = ":struct_list.nested_str_list",
)
cc_nested_args(
name = "simple_str",
args = [format_arg("%s", ":str")],
)
cc_nested_args(
name = "list_not_allowed",
args = [format_arg("%s", ":str_list")],
)
cc_nested_args(
name = "iterate_over_list",
args = [format_arg("%s")],
iterate_over = ":str_list",
)
cc_nested_args(
name = "iterate_over_non_list",
args = ["--foo"],
iterate_over = ":str",
)
cc_nested_args(
name = "str_not_a_bool",
args = ["--foo"],
requires_true = ":str",
)
cc_nested_args(
name = "str_equal",
args = ["--foo"],
requires_equal = ":str",
requires_equal_value = "bar",
)
cc_nested_args(
name = "inner_iter",
args = [format_arg("%s")],
iterate_over = ":struct_list.nested_str_list",
)
cc_nested_args(
name = "outer_iter",
iterate_over = ":struct_list",
nested = [":inner_iter"],
)
cc_nested_args(
name = "bad_inner_iter",
args = [format_arg("%s", ":struct_list.nested_str_list")],
)
cc_nested_args(
name = "bad_outer_iter",
iterate_over = ":struct_list",
nested = [":bad_inner_iter"],
)
cc_nested_args(
name = "bad_nested_optional",
args = [format_arg("%s", ":str_option")],
)
cc_nested_args(
name = "good_nested_optional",
args = [format_arg("%s", ":str_option")],
requires_not_none = ":str_option",
)
cc_nested_args(
name = "optional_list_iter",
args = ["--foo"],
iterate_over = ":optional_list",
)
cc_builtin_variables(
name = "variables",
srcs = [
":optional_list",
":str",
":str_list",
":str_option",
":struct",
":struct_list",
],
)
analysis_test_suite(
name = "test_suite",
targets = TARGETS,
tests = TESTS,
)
|