8000 fix: replace string with modern providers in tests (#2773) · keith/rules_python@79abef8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 79abef8

Browse files
authored
fix: replace string with modern providers in tests (bazel-contrib#2773)
Strings used to refer to legacy struct providers, which were removed from Bazel. Legacy struct providers have been deprecated by Bazel. Replacing them with modern providers, will make it possible to simplify and remove legacy handling from Blaze. The change is a no-op. More information: bazelbuild/bazel#25836
1 parent 2cb920c commit 79abef8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/builders/attr_builders_tests.bzl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def _expect_cfg_defaults(expect, cfg):
2828
expect.where(expr = "cfg.which_cfg").that_str(cfg.which_cfg()).equals("target")
2929

3030
_some_aspect = aspect(implementation = lambda target, ctx: None)
31+
_SomeInfo = provider("MyInfo", fields = [])
3132

3233
_tests = []
3334

@@ -186,7 +187,7 @@ def _test_label(name):
186187
subject.set_executable(True)
187188
subject.add_allow_files(".txt")
188189
subject.cfg.set_target()
189-
subject.providers().append("provider")
190+
subject.providers().append(_SomeInfo)
190191
subject.aspects().append(_some_aspect)
191192
subject.cfg.outputs().append(Label("//some:output"))
192193
subject.cfg.inputs().append(Label("//some:input"))
@@ -199,7 +200,7 @@ def _test_label(name):
199200
expect.that_bool(subject.executable()).equals(True)
200201
expect.that_collection(subject.allow_files()).contains_exactly([".txt"])
201202
expect.that_bool(subject.allow_single_file()).equals(None)
202-
expect.that_collection(subject.providers()).contains_exactly(["provider"])
203+
expect.that_collection(subject.providers()).contains_exactly([_SomeInfo])
203204
expect.that_collection(subject.aspects()).contains_exactly([_some_aspect])
204205
expect.that_collection(subject.cfg.outputs()).contains_exactly([Label("//some:output")])
205206
expect.that_collection(subject.cfg.inputs()).contains_exactly([Label("//some:input")])
@@ -229,7 +230,7 @@ def _test_label_keyed_string_dict(name):
229230
subject.set_mandatory(True)
230231
10000 subject.set_allow_files(True)
231232
subject.cfg.set_target()
232-
subject.providers().append("provider")
233+
subject.providers().append(_SomeInfo)
233234
subject.aspects().append(_some_aspect)
234235
subject.cfg.outputs().append("//some:output")
235236
subject.cfg.inputs().append("//some:input")
@@ -240,7 +241,7 @@ def _test_label_keyed_string_dict(name):
240241
expect.that_str(subject.doc()).equals("doc")
241242
expect.that_bool(subject.mandatory()).equals(True)
242243
expect.that_bool(subject.allow_files()).equals(True)
243-
expect.that_collection(subject.providers()).contains_exactly(["provider"])
244+
expect.that_collection(subject.providers()).contains_exactly([_SomeInfo])
244245
expect.that_collection(subject.aspects()).contains_exactly([_some_aspect])
245246
expect.that_collection(subject.cfg.outputs()).contains_exactly(["//some:output"])
246247
expect.that_collection(subject.cfg.inputs()).contains_exactly(["//some:input"])
@@ -274,14 +275,14 @@ def _test_label_list(name):
274275
subject.set_doc("doc")
275276
subject.set_mandatory(True)
276277
subject.set_allow_files([".txt"])
277-
subject.providers().append("provider")
278+
subject.providers().append(_SomeInfo)
278279
subject.aspects().append(_some_aspect)
279280

280281
expect.that_collection(subject.default()).contains_exactly(["//some:label"])
281282
expect.that_str(subject.doc()).equals("doc")
282283
expect.that_bool(subject.mandatory()).equals(True)
283284
expect.that_collection(subject.allow_files()).contains_exactly([".txt"])
284-
expect.that_collection(subject.providers()).contains_exactly(["provider"])
285+
expect.that_collection(subject.providers()).contains_exactly([_SomeInfo])
285286
expect.that_collection(subject.aspects()).contains_exactly([_some_aspect])
286287

287288
_expect_builds(expect, subject, "attr.label_list")
@@ -395,14 +396,14 @@ def _test_string_keyed_label_dict(name):
395396
subject.set_doc("doc")
396397
subject.set_mandatory(True)
397398
subject.set_allow_files([".txt"])
398-
subject.providers().append("provider")
399+
subject.providers().append(_SomeInfo)
399400
subject.aspects().append(_some_aspect)
400401

401402
expect.that_dict(subject.default()).contains_exactly({"key": "//some:label"})
402403
expect.that_str(subject.doc()).equals("doc")
403404
expect.that_bool(subject.mandatory()).equals(True)
404405
expect.that_collection(subject.allow_files()).contains_exactly([".txt"])
405-
expect.that_collection(subject.providers()).contains_exactly(["provider"])
406+
expect.that_collection(subject.providers()).contains_exactly([_SomeInfo])
406407
expect.that_collection(subject.aspects()).contains_exactly([_some_aspect])
407408

408409
_expect_builds(expect, subject, "attr.string_keyed_label_dict")

0 commit comments

Comments
 (0)
0