C++: Change Skylark API whitelisting to be part of flag.
This uses SkylarkSemantics now instead of the C++ configuration. The flag is:
--experimental_cc_skylark_api_enabled_packages
RELNOTES:none
PiperOrigin-RevId: 207235431
diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
index ed22d1e..21328c8 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java
@@ -16,6 +16,7 @@
import static com.google.common.truth.Truth.assertThat;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext;
import com.google.devtools.build.lib.skyframe.serialization.DynamicCodec;
@@ -36,26 +37,22 @@
*
* <p>When adding a new option, it is trivial to make a transposition error or a copy/paste error.
* These tests guard against such errors. The following possible bugs are considered:
+ *
* <ul>
* <li>If a new option is added to {@code SkylarkSemantics} but not to {@code
* SkylarkSemanticsOptions}, or vice versa, then the programmer will either be unable to
* implement its behavior, or unable to test it from the command line and add user
* documentation. We hope that the programmer notices this on their own.
- *
- * <li>If {@link SkylarkSemanticsOptions#toSkylarkSemantics} or {@link
- * SkylarkSemanticsCodec#deserialize} is not updated to set all fields of {@code
- * SkylarkSemantics}, then it will fail immediately because all fields of {@link
+ * <li>If {@link SkylarkSemanticsOptions#toSkylarkSemantics} is not updated to set all fields of
+ * {@code SkylarkSemantics}, then it will fail immediately because all fields of {@link
* SkylarkSemantics.Builder} are mandatory.
- *
* <li>To catch a copy/paste error where the wrong field's data is threaded through {@code
* toSkylarkSemantics()} or {@code deserialize(...)}, we repeatedly generate matching random
* instances of the input and expected output objects.
- *
* <li>The {@link #checkDefaultsMatch} test ensures that there is no divergence between the
* default values of the two classes.
- *
- * <li>There is no test coverage for failing to update the non-generated webpage documentation.
- * So don't forget that!
+ * <li>There is no test coverage for failing to update the non-generated webpage documentation. So
+ * don't forget that!
* </ul>
*/
@RunWith(JUnit4.class)
@@ -121,6 +118,10 @@
private static SkylarkSemanticsOptions buildRandomOptions(Random rand) throws Exception {
return parseOptions(
// <== Add new options here in alphabetic order ==>
+ "--experimental_cc_skylark_api_enabled_packages="
+ + rand.nextDouble()
+ + ","
+ + rand.nextDouble(),
"--experimental_enable_repo_mapping=" + rand.nextBoolean(),
"--incompatible_bzl_disallow_load_after_statement=" + rand.nextBoolean(),
"--incompatible_depset_is_not_iterable=" + rand.nextBoolean(),
@@ -151,6 +152,8 @@
private static SkylarkSemantics buildRandomSemantics(Random rand) {
return SkylarkSemantics.builder()
// <== Add new options here in alphabetic order ==>
+ .experimentalCcSkylarkApiEnabledPackages(
+ ImmutableList.of(String.valueOf(rand.nextDouble()), String.valueOf(rand.nextDouble())))
.experimentalEnableRepoMapping(rand.nextBoolean())
.incompatibleBzlDisallowLoadAfterStatement(rand.nextBoolean())
.incompatibleDepsetIsNotIterable(rand.nextBoolean())