Skip to content

Commit ef967be

Browse files
laurentlbcopybara-github
authored andcommitted
Flip incompatible_disable_depset_items to true.
The flag was introduced in August 2019 (before Bazel 1.0). Next steps: - update the bazelrc files that refer to the file - remove the flag and simplify the depset code Fixes #9017 RELNOTES: incompatible_disable_depset_items is flipped PiperOrigin-RevId: 400196736
1 parent 10e08c4 commit ef967be

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public class BuildLanguageOptions extends OptionsBase implements Serializable {
324324

325325
@Option(
326326
name = "incompatible_disable_depset_items",
327-
defaultValue = "false",
327+
defaultValue = "true",
328328
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
329329
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
330330
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
@@ -683,7 +683,7 @@ public StarlarkSemantics toStarlarkSemantics() {
683683
public static final String INCOMPATIBLE_DEPSET_FOR_LIBRARIES_TO_LINK_GETTER =
684684
"+incompatible_depset_for_libraries_to_link_getter";
685685
public static final String INCOMPATIBLE_DISABLE_DEPSET_ITEMS =
686-
"-incompatible_disable_depset_items";
686+
"+incompatible_disable_depset_items";
687687
public static final String INCOMPATIBLE_DISABLE_TARGET_PROVIDER_FIELDS =
688688
"-incompatible_disable_target_provider_fields";
689689
public static final String INCOMPATIBLE_DISABLE_THIRD_PARTY_LICENSE_CHECKING =

src/test/java/com/google/devtools/build/lib/collect/nestedset/DepsetTest.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void testGetSetDirect() throws Exception {
103103

104104
@Test
105105
public void testGetSetItems() throws Exception {
106+
ev.setSemantics("--incompatible_disable_depset_items=false");
106107
ev.exec("s = depset(items = ['a', 'b'])");
107108
assertThat(get("s").getSet(String.class).toList()).containsExactly("a", "b").inOrder();
108109
assertThat(get("s").getSet(Object.class).toList()).containsExactly("a", "b").inOrder();
@@ -129,6 +130,7 @@ public void testToListDirect() throws Exception {
129130

130131
@Test
131132
public void testToListItems() throws Exception {
133+
ev.setSemantics("--incompatible_disable_depset_items=false");
132134
ev.exec("s = depset(items = ['a', 'b'])");
133135
assertThat(get("s").toList(String.class)).containsExactly("a", "b").inOrder();
134136
assertThat(get("s").toList(Object.class)).containsExactly("a", "b").inOrder();
@@ -150,6 +152,7 @@ public void testOrderDirect() throws Exception {
150152

151153
@Test
152154
public void testOrderItems() throws Exception {
155+
ev.setSemantics("--incompatible_disable_depset_items=false");
153156
ev.exec("s = depset(items = ['a', 'b'], order='postorder')");
154157
assertThat(get("s").getSet(String.class).getOrder()).isEqualTo(Order.COMPILE_ORDER);
155158
}
@@ -169,7 +172,7 @@ ev.new Scenario()
169172

170173
@Test
171174
public void testBadOrderItems() throws Exception {
172-
ev.new Scenario()
175+
ev.new Scenario("--incompatible_disable_depset_items=false")
173176
.testIfExactError(
174177
"Invalid order: non_existing", "depset(items = ['a'], order='non_existing')");
175178
}
@@ -182,33 +185,34 @@ public void testEmptyGenericType() throws Exception {
182185

183186
@Test
184187
public void testHomogeneousGenericType() throws Exception {
185-
ev.exec("s = depset(['a', 'b', 'c'])");
188+
ev.exec("s = depset(direct = ['a', 'b', 'c'])");
186189
assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
187190
}
188191

189192
@Test
190193
public void testHomogeneousGenericTypeDirect() throws Exception {
191-
ev.exec("s = depset(['a', 'b', 'c'], transitive = [])");
194+
ev.exec("s = depset(direct = ['a', 'b', 'c'], transitive = [])");
192195
assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
193196
}
194197

195198
@Test
196199
public void testHomogeneousGenericTypeItems() throws Exception {
200+
ev.setSemantics("--incompatible_disable_depset_items=false");
197201
ev.exec("s = depset(items = ['a', 'b', 'c'], transitive = [])");
198202
assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
199203
}
200204

201205
@Test
202206
public void testHomogeneousGenericTypeTransitive() throws Exception {
203-
ev.exec("s = depset(['a', 'b', 'c'], transitive = [depset(['x'])])");
207+
ev.exec("s = depset(direct = ['a', 'b', 'c'], transitive = [depset(['x'])])");
204208
assertThat(get("s").getElementType()).isEqualTo(ElementType.STRING);
205209
}
206210

207211
@Test
208212
public void testTransitiveIncompatibleOrder() throws Exception {
209213
ev.checkEvalError(
210214
"Order 'postorder' is incompatible with order 'topological'",
211-
"depset(['a', 'b'], order='postorder',",
215+
"depset(direct = ['a', 'b'], order='postorder',",
212216
" transitive = [depset(['c', 'd'], order='topological')])");
213217
}
214218

@@ -229,7 +233,7 @@ ev.new Scenario()
229233

230234
@Test
231235
public void testBadGenericTypeItems() throws Exception {
232-
ev.new Scenario()
236+
ev.new Scenario("--incompatible_disable_depset_items=false")
233237
.testIfExactError(
234238
"cannot add an item of type 'int' to a depset of 'string'", "depset(items = ['a', 5])");
235239
}
@@ -244,15 +248,15 @@ ev.new Scenario()
244248

245249
@Test
246250
public void testLegacyAndNewApi() throws Exception {
247-
ev.new Scenario()
251+
ev.new Scenario("--incompatible_disable_depset_items=false")
248252
.testIfExactError(
249253
"Do not pass both 'direct' and 'items' argument to depset constructor.",
250254
"depset(['a', 'b'], direct = ['c', 'd'])");
251255
}
252256

253257
@Test
254258
public void testItemsAndTransitive() throws Exception {
255-
ev.new Scenario()
259+
ev.new Scenario("--incompatible_disable_depset_items=false")
256260
.testIfExactError(
257261
"for items, got depset, want sequence",
258262
"depset(items = depset(), transitive = [depset()])");
@@ -269,6 +273,7 @@ ev.new Scenario()
269273

270274
@Test
271275
public void testTransitiveOrder() throws Exception {
276+
ev.setSemantics("--incompatible_disable_depset_items=false");
272277
assertContainsInOrder("depset([], transitive=[depset(['a', 'b', 'c'])])", "a", "b", "c");
273278
assertContainsInOrder("depset(['a'], transitive = [depset(['b', 'c'])])", "b", "c", "a");
274279
assertContainsInOrder("depset(['a', 'b'], transitive = [depset(['c'])])", "c", "a", "b");
@@ -277,6 +282,7 @@ public void testTransitiveOrder() throws Exception {
277282

278283
@Test
279284
public void testTransitiveOrderItems() throws Exception {
285+
ev.setSemantics("--incompatible_disable_depset_items=false");
280286
assertContainsInOrder("depset(items=[], transitive=[depset(['a', 'b', 'c'])])", "a", "b", "c");
281287
assertContainsInOrder("depset(items=['a'], transitive = [depset(['b', 'c'])])", "b", "c", "a");
282288
assertContainsInOrder("depset(items=['a', 'b'], transitive = [depset(['c'])])", "c", "a", "b");
@@ -385,7 +391,9 @@ private static boolean areOrdersCompatible(Order first, Order second) {
385391
@Test
386392
public void testMutableDepsetElementsLegacyBehavior() throws Exception {
387393
// See b/144992997 and github.com/bazelbuild/bazel/issues/10313.
388-
ev.setSemantics("--incompatible_always_check_depset_elements=false");
394+
ev.setSemantics(
395+
"--incompatible_always_check_depset_elements=false",
396+
"--incompatible_disable_depset_items=false");
389397

390398
// Test legacy depset(...) and new depset(direct=...) constructors.
391399

src/test/java/com/google/devtools/build/lib/starlark/StarlarkIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public void testOutputGroupsAsDictionaryPipe() throws Exception {
371371
"test/starlark/extension.bzl",
372372
"load('//myinfo:myinfo.bzl', 'MyInfo')",
373373
"def _impl(ctx):",
374-
" g = depset(ctx.attr.dep.output_groups['_hidden_top_level" + INTERNAL_SUFFIX + "'])",
374+
" g = ctx.attr.dep.output_groups['_hidden_top_level" + INTERNAL_SUFFIX + "']",
375375
" return [MyInfo(result = g),",
376376
" OutputGroupInfo(my_group = g)]",
377377
"my_rule = rule(implementation = _impl,",

src/test/shell/integration/py_args_escaping_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _impl(ctx):
298298
use_default_shell_env = True,
299299
input_manifests = tool_input_mfs,
300300
)
301-
return DefaultInfo(files = depset(items = [ctx.outputs.out]))
301+
return DefaultInfo(files = depset(direct = [ctx.outputs.out]))
302302
303303
run_host_configured = rule(
304304
implementation = _impl,

0 commit comments

Comments
 (0)