summaryrefslogtreecommitdiff
path: root/test/RULES
blob: 3aec6e1499c35f9f35fefa57caa6910cc01bdaa4 (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{ "suite":
  { "doc":
    [ "Form a compound target out of many test targets."
    , ""
    , "More precisely, take the runfiles of the given \"deps\", take their"
    , "disjoint union and stage the result. Also propagate relevant"
    , "providers."
    ]
  , "tainted": ["test"]
  , "target_fields": ["deps"]
  , "string_fields": ["stage"]
  , "field_doc":
    { "deps": ["The targets that suite is composed of."]
    , "stage":
      [ "The logical location this test suite is to be placed."
      , "Individual entries will be joined with \"/\"."
      ]
    }
  , "artifacts_doc":
    [ "The disjoint union of the runfiles of the \"deps\" targets"
    , "staged as the location given by \"stage\"."
    ]
  , "runfiles_doc": ["Same as artifacts."]
  , "imports":
    { "runfiles": ["", "field_runfiles"]
    , "list_provider": ["", "field_list_provider"]
    }
  , "expression":
    { "type": "let*"
    , "bindings":
      [ ["fieldname", "deps"]
      , ["runfiles", {"type": "CALL_EXPRESSION", "name": "runfiles"}]
      , [ "stage"
        , { "type": "join"
          , "separator": "/"
          , "$1": {"type": "FIELD", "name": "stage"}
          }
        ]
      , [ "staged results"
        , { "type": "to_subdir"
          , "subdir": {"type": "var", "name": "stage"}
          , "$1": {"type": "var", "name": "runfiles"}
          }
        ]
      , ["provider", "lint"]
      , ["lint", {"type": "CALL_EXPRESSION", "name": "list_provider"}]
      , ["lint", {"type": "nub_right", "$1": {"type": "var", "name": "lint"}}]
      ]
    , "body":
      { "type": "RESULT"
      , "artifacts": {"type": "var", "name": "staged results"}
      , "runfiles": {"type": "var", "name": "staged results"}
      , "provides": {"type": "env", "vars": ["lint"]}
      }
    }
  }
, "matrix":
  { "doc":
    [ "Given a group of tests, build them in a variety of configurations."
    , ""
    , "The configuration variable TEST_MATRIX is expected to be a map with"
    , "each value being a map itself. Sequentially for each key, all possible"
    , "values of the associated map are tried and staged to the appropriate"
    , "key. Thus, the tests in \"deps\" are built in an exponential number of"
    , "configurations."
    , ""
    , "If TEST_MATRIX is unset, {} will be assumed, i.e., all the \"deps\" will"
    , "be built precisely once, in the current configuration. In this way,"
    , "the \"matrix\" rule can be used instead of the \"suite\" rule to allow"
    , "user-defined configuration matrices, dispatching over parameters for"
    , "dependencies (e.g., the toolchain)."
    ]
  , "tainted": ["test"]
  , "config_vars": ["TEST_MATRIX"]
  , "target_fields": ["deps"]
  , "string_fields": ["stage"]
  , "field_doc":
    { "deps": ["The targets that suite is composed of."]
    , "stage":
      [ "The logical location this test suite is to be placed."
      , "Individual entries will be joined with \"/\"."
      ]
    }
  , "config_doc":
    { "TEST_MATRIX":
      [ "Map describing the dimensions of the matrix to run the tests for."
      , ""
      , "Keys are config variables. The value for each key has to be a map"
      , "mapping the stage name to the corresponding value for that config"
      , "variable."
      ]
    }
  , "artifacts_doc":
    [ "The disjoint union of the runfiles of the \"deps\" targets,"
    , "evaluated and staged as requested by TEST_MATRIX and finally"
    , "staged to the location given by \"stage\"."
    ]
  , "runfiles_doc": ["Same as artifacts."]
  , "imports":
    { "runfiles": ["", "field_runfiles"]
    , "list_provider": ["", "field_list_provider"]
    , "matrix": "matrix"
    }
  , "config_transitions":
    { "deps":
      { "type": "++"
      , "$1":
        { "type": "foreach"
        , "range": {"type": "CALL_EXPRESSION", "name": "matrix"}
        , "body": {"type": "values", "$1": {"type": "var", "name": "_"}}
        }
      }
    }
  , "expression":
    { "type": "let*"
    , "bindings":
      [ ["matrix", {"type": "CALL_EXPRESSION", "name": "matrix"}]
      , ["fieldname", "deps"]
      , [ "staged runfiles list"
        , { "type": "foreach"
          , "range": {"type": "var", "name": "matrix"}
          , "body":
            { "type": "foreach_map"
            , "range": {"type": "var", "name": "_"}
            , "var_val": "transition"
            , "body":
              { "type": "to_subdir"
              , "subdir": {"type": "var", "name": "_"}
              , "$1": {"type": "CALL_EXPRESSION", "name": "runfiles"}
              }
            }
          }
        ]
      , [ "staged matrix runfiles"
        , { "type": "disjoint_map_union"
          , "$1":
            { "type": "++"
            , "$1": {"type": "var", "name": "staged runfiles list"}
            }
          }
        ]
      , [ "stage"
        , { "type": "join"
          , "separator": "/"
          , "$1": {"type": "FIELD", "name": "stage"}
          }
        ]
      , [ "staged results"
        , { "type": "to_subdir"
          , "subdir": {"type": "var", "name": "stage"}
          , "$1": {"type": "var", "name": "staged matrix runfiles"}
          }
        ]
      , ["provider", "lint"]
      , [ "lint"
        , { "type": "++"
          , "$1":
            { "type": "++"
            , "$1":
              { "type": "foreach"
              , "range": {"type": "var", "name": "matrix"}
              , "body":
                { "type": "foreach_map"
                , "range": {"type": "var", "name": "_"}
                , "var_val": "transition"
                , "body": {"type": "CALL_EXPRESSION", "name": "list_provider"}
                }
              }
            }
          }
        ]
      , ["lint", {"type": "nub_right", "$1": {"type": "var", "name": "lint"}}]
      ]
    , "body":
      { "type": "RESULT"
      , "artifacts": {"type": "var", "name": "staged results"}
      , "runfiles": {"type": "var", "name": "staged results"}
      , "provides": {"type": "env", "vars": ["lint"]}
      }
    }
  }
}