ichern | 585647e | 2020-01-15 00:37:44 -0800 | [diff] [blame] | 1 | // Copyright 2019 The Bazel Authors. All rights reserved. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
ichern | 585647e | 2020-01-15 00:37:44 -0800 | [diff] [blame] | 14 | // |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 15 | |
| 16 | package com.google.devtools.build.lib.packages; |
| 17 | |
| 18 | import static com.google.common.truth.Truth.assertThat; |
| 19 | |
plf | 7e41f9b | 2018-08-03 01:47:22 -0700 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableList; |
shahan | fae34b9 | 2018-02-13 10:08:47 -0800 | [diff] [blame] | 21 | import com.google.common.collect.ImmutableMap; |
| 22 | import com.google.devtools.build.lib.skyframe.serialization.DeserializationContext; |
plf | 504a6d2 | 2018-07-31 08:41:20 -0700 | [diff] [blame] | 23 | import com.google.devtools.build.lib.skyframe.serialization.DynamicCodec; |
shahan | fae34b9 | 2018-02-13 10:08:47 -0800 | [diff] [blame] | 24 | import com.google.devtools.build.lib.skyframe.serialization.SerializationContext; |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 25 | import com.google.devtools.build.lib.skyframe.serialization.testutils.TestUtils; |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 26 | import com.google.devtools.build.lib.syntax.StarlarkSemantics; |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 27 | import com.google.devtools.common.options.Options; |
| 28 | import com.google.devtools.common.options.OptionsParser; |
| 29 | import java.util.Arrays; |
| 30 | import java.util.Random; |
| 31 | import org.junit.Test; |
| 32 | import org.junit.runner.RunWith; |
| 33 | import org.junit.runners.JUnit4; |
| 34 | |
| 35 | /** |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 36 | * Tests for the flow of flags from {@link StarlarkSemanticsOptions} to {@link StarlarkSemantics}, |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 37 | * and to and from {@code StarlarkSemantics}' serialized representation. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 38 | * |
| 39 | * <p>When adding a new option, it is trivial to make a transposition error or a copy/paste error. |
| 40 | * These tests guard against such errors. The following possible bugs are considered: |
plf | 7e41f9b | 2018-08-03 01:47:22 -0700 | [diff] [blame] | 41 | * |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 42 | * <ul> |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 43 | * <li>If a new option is added to {@code StarlarkSemantics} but not to {@code |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 44 | * StarlarkSemanticsOptions}, or vice versa, then the programmer will either be unable to |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 45 | * implement its behavior, or unable to test it from the command line and add user |
| 46 | * documentation. We hope that the programmer notices this on their own. |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 47 | * <li>If {@link StarlarkSemanticsOptions#toStarlarkSemantics} is not updated to set all fields of |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 48 | * {@code StarlarkSemantics}, then it will fail immediately because all fields of {@link |
| 49 | * StarlarkSemantics.Builder} are mandatory. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 50 | * <li>To catch a copy/paste error where the wrong field's data is threaded through {@code |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 51 | * toStarlarkSemantics()} or {@code deserialize(...)}, we repeatedly generate matching random |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 52 | * instances of the input and expected output objects. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 53 | * <li>The {@link #checkDefaultsMatch} test ensures that there is no divergence between the |
| 54 | * default values of the two classes. |
plf | 7e41f9b | 2018-08-03 01:47:22 -0700 | [diff] [blame] | 55 | * <li>There is no test coverage for failing to update the non-generated webpage documentation. So |
| 56 | * don't forget that! |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 57 | * </ul> |
| 58 | */ |
| 59 | @RunWith(JUnit4.class) |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 60 | public class StarlarkSemanticsConsistencyTest { |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 61 | |
| 62 | private static final int NUM_RANDOM_TRIALS = 10; |
| 63 | |
| 64 | /** |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 65 | * Checks that a randomly generated {@link StarlarkSemanticsOptions} object can be converted to a |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 66 | * {@link StarlarkSemantics} object with the same field values. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 67 | */ |
| 68 | @Test |
| 69 | public void optionsToSemantics() throws Exception { |
| 70 | for (int i = 0; i < NUM_RANDOM_TRIALS; i++) { |
| 71 | long seed = i; |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 72 | StarlarkSemanticsOptions options = buildRandomOptions(new Random(seed)); |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 73 | StarlarkSemantics semantics = buildRandomSemantics(new Random(seed)); |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 74 | StarlarkSemantics semanticsFromOptions = options.toStarlarkSemantics(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 75 | assertThat(semanticsFromOptions).isEqualTo(semantics); |
| 76 | } |
| 77 | } |
| 78 | |
brandjon | 6ac92f9 | 2017-12-06 13:57:15 -0800 | [diff] [blame] | 79 | /** |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 80 | * Checks that a randomly generated {@link StarlarkSemantics} object can be serialized and |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 81 | * deserialized to an equivalent object. |
| 82 | */ |
| 83 | @Test |
| 84 | public void serializationRoundTrip() throws Exception { |
plf | 504a6d2 | 2018-07-31 08:41:20 -0700 | [diff] [blame] | 85 | DynamicCodec codec = new DynamicCodec(buildRandomSemantics(new Random(2)).getClass()); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 86 | for (int i = 0; i < NUM_RANDOM_TRIALS; i++) { |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 87 | StarlarkSemantics semantics = buildRandomSemantics(new Random(i)); |
| 88 | StarlarkSemantics deserialized = |
| 89 | (StarlarkSemantics) |
| 90 | TestUtils.fromBytes( |
| 91 | new DeserializationContext(ImmutableMap.of()), |
| 92 | codec, |
| 93 | TestUtils.toBytes(new SerializationContext(ImmutableMap.of()), codec, semantics)); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 94 | assertThat(deserialized).isEqualTo(semantics); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | @Test |
| 99 | public void checkDefaultsMatch() { |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 100 | StarlarkSemanticsOptions defaultOptions = Options.getDefaults(StarlarkSemanticsOptions.class); |
adonovan | b85d0b7 | 2020-05-08 11:59:19 -0700 | [diff] [blame] | 101 | StarlarkSemantics defaultSemantics = StarlarkSemantics.DEFAULT; |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 102 | StarlarkSemantics semanticsFromOptions = defaultOptions.toStarlarkSemantics(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 103 | assertThat(semanticsFromOptions).isEqualTo(defaultSemantics); |
| 104 | } |
| 105 | |
brandjon | 6ac92f9 | 2017-12-06 13:57:15 -0800 | [diff] [blame] | 106 | @Test |
| 107 | public void canGetBuilderFromInstance() { |
adonovan | b85d0b7 | 2020-05-08 11:59:19 -0700 | [diff] [blame] | 108 | StarlarkSemantics original = StarlarkSemantics.DEFAULT; |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 109 | assertThat(original.internalStarlarkFlagTestCanary()).isFalse(); |
| 110 | StarlarkSemantics modified = original.toBuilder().internalStarlarkFlagTestCanary(true).build(); |
| 111 | assertThat(modified.internalStarlarkFlagTestCanary()).isTrue(); |
brandjon | 6ac92f9 | 2017-12-06 13:57:15 -0800 | [diff] [blame] | 112 | } |
| 113 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 114 | /** |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 115 | * Constructs a {@link StarlarkSemanticsOptions} object with random fields. Must access {@code |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 116 | * rand} using the same sequence of operations (for the same fields) as {@link |
| 117 | * #buildRandomSemantics}. |
| 118 | */ |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 119 | private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws Exception { |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 120 | return parseOptions( |
| 121 | // <== Add new options here in alphabetic order ==> |
cparsons | 2b6a435 | 2019-10-28 16:30:34 -0700 | [diff] [blame] | 122 | "--experimental_action_args=" + rand.nextBoolean(), |
lberki | 015f586 | 2020-02-20 10:08:29 -0800 | [diff] [blame] | 123 | "--experimental_disable_external_package=" + rand.nextBoolean(), |
Jingwen Chen | 6360557 | 2020-02-13 13:47:00 -0800 | [diff] [blame] | 124 | "--experimental_sibling_repository_layout=" + rand.nextBoolean(), |
Googler | 137019f | 2019-04-23 02:23:37 -0700 | [diff] [blame] | 125 | "--experimental_allow_incremental_repository_updates=" + rand.nextBoolean(), |
brandjon | 6c5f911 | 2020-05-27 08:28:39 -0700 | [diff] [blame] | 126 | "--experimental_builtins_bzl_path=" + rand.nextDouble(), |
plf | 7e41f9b | 2018-08-03 01:47:22 -0700 | [diff] [blame] | 127 | "--experimental_cc_skylark_api_enabled_packages=" |
| 128 | + rand.nextDouble() |
| 129 | + "," |
| 130 | + rand.nextDouble(), |
Googler | c2cd957 | 2018-10-02 14:38:15 -0700 | [diff] [blame] | 131 | "--experimental_enable_android_migration_apis=" + rand.nextBoolean(), |
cparsons | ed6bfbe | 2019-04-19 10:17:03 -0700 | [diff] [blame] | 132 | "--experimental_google_legacy_api=" + rand.nextBoolean(), |
ichern | 585647e | 2020-01-15 00:37:44 -0800 | [diff] [blame] | 133 | "--experimental_ninja_actions=" + rand.nextBoolean(), |
cparsons | 140c076 | 2018-10-05 14:07:19 -0700 | [diff] [blame] | 134 | "--experimental_platforms_api=" + rand.nextBoolean(), |
cparsons | e0efc14 | 2018-10-17 09:39:10 -0700 | [diff] [blame] | 135 | "--experimental_starlark_config_transitions=" + rand.nextBoolean(), |
Googler | 5736381 | 2019-05-28 07:24:13 -0700 | [diff] [blame] | 136 | "--experimental_starlark_unused_inputs_list=" + rand.nextBoolean(), |
Googler | 7450e10 | 2019-11-26 13:52:51 -0800 | [diff] [blame] | 137 | "--incompatible_allow_tags_propagation=" + rand.nextBoolean(), // flag, Java names differ |
plf | d6c8766 | 2019-11-05 01:14:03 -0800 | [diff] [blame] | 138 | "--experimental_cc_shared_library=" + rand.nextBoolean(), |
buchgr | 755e29d | 2019-11-19 05:34:15 -0800 | [diff] [blame] | 139 | "--experimental_repo_remote_exec=" + rand.nextBoolean(), |
juliexxia | 1dbf854 | 2020-03-24 08:41:57 -0700 | [diff] [blame] | 140 | "--experimental_exec_groups=" + rand.nextBoolean(), |
Googler | 7450e10 | 2019-11-26 13:52:51 -0800 | [diff] [blame] | 141 | "--incompatible_always_check_depset_elements=" + rand.nextBoolean(), |
aiuto | 8ea115e | 2020-01-31 13:19:58 -0800 | [diff] [blame] | 142 | "--incompatible_applicable_licenses=" + rand.nextBoolean(), |
plf | 0d40b7f | 2019-04-29 08:09:11 -0700 | [diff] [blame] | 143 | "--incompatible_depset_for_libraries_to_link_getter=" + rand.nextBoolean(), |
cparsons | f1ee74d | 2019-07-31 07:09:53 -0700 | [diff] [blame] | 144 | "--incompatible_disable_target_provider_fields=" + rand.nextBoolean(), |
cparsons | e506858 | 2018-07-16 13:33:33 -0700 | [diff] [blame] | 145 | "--incompatible_disable_deprecated_attr_params=" + rand.nextBoolean(), |
cparsons | f0cf2b4 | 2019-08-15 10:56:40 -0700 | [diff] [blame] | 146 | "--incompatible_disable_depset_items=" + rand.nextBoolean(), |
gregce | 4aa059a | 2019-02-26 13:20:47 -0800 | [diff] [blame] | 147 | "--incompatible_disable_third_party_license_checking=" + rand.nextBoolean(), |
laurentlb | 9bc841e | 2019-05-28 05:59:35 -0700 | [diff] [blame] | 148 | "--incompatible_disallow_empty_glob=" + rand.nextBoolean(), |
Marwan Tammam | 7150aab | 2019-07-11 08:40:40 -0700 | [diff] [blame] | 149 | "--incompatible_disallow_struct_provider_syntax=" + rand.nextBoolean(), |
plf | 0d40b7f | 2019-04-29 08:09:11 -0700 | [diff] [blame] | 150 | "--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean(), |
plf | 906f5f1 | 2020-03-06 05:44:46 -0800 | [diff] [blame] | 151 | "--incompatible_linkopts_to_linklibs=" + rand.nextBoolean(), |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 152 | "--incompatible_new_actions_api=" + rand.nextBoolean(), |
laurentlb | d8d3776 | 2018-10-26 14:08:33 -0700 | [diff] [blame] | 153 | "--incompatible_no_attr_license=" + rand.nextBoolean(), |
Klaus Aehlig | 2bb1bf9 | 2019-10-31 10:28:44 -0700 | [diff] [blame] | 154 | "--incompatible_no_implicit_file_export=" + rand.nextBoolean(), |
cparsons | 36c70a6 | 2019-06-07 09:31:14 -0700 | [diff] [blame] | 155 | "--incompatible_no_rule_outputs_param=" + rand.nextBoolean(), |
tomlu | aaf11e9 | 2018-06-02 10:20:16 -0700 | [diff] [blame] | 156 | "--incompatible_no_support_tools_in_action_inputs=" + rand.nextBoolean(), |
cparsons | c750f97 | 2019-06-13 15:52:40 -0700 | [diff] [blame] | 157 | "--incompatible_run_shell_command_string=" + rand.nextBoolean(), |
Gustav Westling | 00ea8fa | 2020-05-01 06:49:01 -0700 | [diff] [blame] | 158 | "--incompatible_string_replace_count=" + rand.nextBoolean(), |
Klaus Aehlig | 752ffcc | 2019-10-31 02:49:39 -0700 | [diff] [blame] | 159 | "--incompatible_visibility_private_attributes_at_definition=" + rand.nextBoolean(), |
plf | 8efc50e | 2020-02-25 07:11:14 -0800 | [diff] [blame] | 160 | "--incompatible_require_linker_input_cc_api=" + rand.nextBoolean(), |
Marwan Tammam | 20c8413 | 2019-06-04 07:27:31 -0700 | [diff] [blame] | 161 | "--incompatible_restrict_string_escapes=" + rand.nextBoolean(), |
hlopko | 23f052f | 2019-11-15 06:55:09 -0800 | [diff] [blame] | 162 | "--incompatible_use_cc_configure_from_rules_cc=" + rand.nextBoolean(), |
gregce | c1c613d | 2020-06-09 09:11:37 -0700 | [diff] [blame] | 163 | "--internal_starlark_flag_test_canary=" + rand.nextBoolean(), |
adonovan | 553a0e4 | 2020-03-18 13:46:47 -0700 | [diff] [blame] | 164 | "--max_computation_steps=" + rand.nextLong(), |
adonovan | 40a737c | 2020-03-11 14:32:19 -0700 | [diff] [blame] | 165 | "--record_rule_instantiation_callstack=" + rand.nextBoolean()); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /** |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 169 | * Constructs a {@link StarlarkSemantics} object with random fields. Must access {@code rand} |
| 170 | * using the same sequence of operations (for the same fields) as {@link #buildRandomOptions}. |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 171 | */ |
laurentlb | 6659b4c | 2019-02-18 07:23:36 -0800 | [diff] [blame] | 172 | private static StarlarkSemantics buildRandomSemantics(Random rand) { |
| 173 | return StarlarkSemantics.builder() |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 174 | // <== Add new options here in alphabetic order ==> |
cparsons | 2b6a435 | 2019-10-28 16:30:34 -0700 | [diff] [blame] | 175 | .experimentalActionArgs(rand.nextBoolean()) |
lberki | 015f586 | 2020-02-20 10:08:29 -0800 | [diff] [blame] | 176 | .experimentalDisableExternalPackage(rand.nextBoolean()) |
Jingwen Chen | 6360557 | 2020-02-13 13:47:00 -0800 | [diff] [blame] | 177 | .experimentalSiblingRepositoryLayout(rand.nextBoolean()) |
Googler | 137019f | 2019-04-23 02:23:37 -0700 | [diff] [blame] | 178 | .experimentalAllowIncrementalRepositoryUpdates(rand.nextBoolean()) |
brandjon | 6c5f911 | 2020-05-27 08:28:39 -0700 | [diff] [blame] | 179 | .experimentalBuiltinsBzlPath(String.valueOf(rand.nextDouble())) |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 180 | .experimentalCcStarlarkApiEnabledPackages( |
plf | 7e41f9b | 2018-08-03 01:47:22 -0700 | [diff] [blame] | 181 | ImmutableList.of(String.valueOf(rand.nextDouble()), String.valueOf(rand.nextDouble()))) |
Googler | c2cd957 | 2018-10-02 14:38:15 -0700 | [diff] [blame] | 182 | .experimentalEnableAndroidMigrationApis(rand.nextBoolean()) |
cparsons | ed6bfbe | 2019-04-19 10:17:03 -0700 | [diff] [blame] | 183 | .experimentalGoogleLegacyApi(rand.nextBoolean()) |
ichern | 585647e | 2020-01-15 00:37:44 -0800 | [diff] [blame] | 184 | .experimentalNinjaActions(rand.nextBoolean()) |
cparsons | 140c076 | 2018-10-05 14:07:19 -0700 | [diff] [blame] | 185 | .experimentalPlatformsApi(rand.nextBoolean()) |
cparsons | e0efc14 | 2018-10-17 09:39:10 -0700 | [diff] [blame] | 186 | .experimentalStarlarkConfigTransitions(rand.nextBoolean()) |
Googler | 5736381 | 2019-05-28 07:24:13 -0700 | [diff] [blame] | 187 | .experimentalStarlarkUnusedInputsList(rand.nextBoolean()) |
ishikhman | 7e83721 | 2019-08-21 03:22:35 -0700 | [diff] [blame] | 188 | .experimentalAllowTagsPropagation(rand.nextBoolean()) |
plf | d6c8766 | 2019-11-05 01:14:03 -0800 | [diff] [blame] | 189 | .experimentalCcSharedLibrary(rand.nextBoolean()) |
buchgr | 755e29d | 2019-11-19 05:34:15 -0800 | [diff] [blame] | 190 | .experimentalRepoRemoteExec(rand.nextBoolean()) |
juliexxia | 1dbf854 | 2020-03-24 08:41:57 -0700 | [diff] [blame] | 191 | .experimentalExecGroups(rand.nextBoolean()) |
Googler | 7450e10 | 2019-11-26 13:52:51 -0800 | [diff] [blame] | 192 | .incompatibleAlwaysCheckDepsetElements(rand.nextBoolean()) |
aiuto | 8ea115e | 2020-01-31 13:19:58 -0800 | [diff] [blame] | 193 | .incompatibleApplicableLicenses(rand.nextBoolean()) |
plf | 0d40b7f | 2019-04-29 08:09:11 -0700 | [diff] [blame] | 194 | .incompatibleDepsetForLibrariesToLinkGetter(rand.nextBoolean()) |
cparsons | f1ee74d | 2019-07-31 07:09:53 -0700 | [diff] [blame] | 195 | .incompatibleDisableTargetProviderFields(rand.nextBoolean()) |
cparsons | e506858 | 2018-07-16 13:33:33 -0700 | [diff] [blame] | 196 | .incompatibleDisableDeprecatedAttrParams(rand.nextBoolean()) |
cparsons | f0cf2b4 | 2019-08-15 10:56:40 -0700 | [diff] [blame] | 197 | .incompatibleDisableDepsetItems(rand.nextBoolean()) |
gregce | 4aa059a | 2019-02-26 13:20:47 -0800 | [diff] [blame] | 198 | .incompatibleDisableThirdPartyLicenseChecking(rand.nextBoolean()) |
laurentlb | 9bc841e | 2019-05-28 05:59:35 -0700 | [diff] [blame] | 199 | .incompatibleDisallowEmptyGlob(rand.nextBoolean()) |
Marwan Tammam | 7150aab | 2019-07-11 08:40:40 -0700 | [diff] [blame] | 200 | .incompatibleDisallowStructProviderSyntax(rand.nextBoolean()) |
plf | 0d40b7f | 2019-04-29 08:09:11 -0700 | [diff] [blame] | 201 | .incompatibleDoNotSplitLinkingCmdline(rand.nextBoolean()) |
plf | 906f5f1 | 2020-03-06 05:44:46 -0800 | [diff] [blame] | 202 | .incompatibleLinkoptsToLinkLibs(rand.nextBoolean()) |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 203 | .incompatibleNewActionsApi(rand.nextBoolean()) |
laurentlb | d8d3776 | 2018-10-26 14:08:33 -0700 | [diff] [blame] | 204 | .incompatibleNoAttrLicense(rand.nextBoolean()) |
Klaus Aehlig | 2bb1bf9 | 2019-10-31 10:28:44 -0700 | [diff] [blame] | 205 | .incompatibleNoImplicitFileExport(rand.nextBoolean()) |
cparsons | 36c70a6 | 2019-06-07 09:31:14 -0700 | [diff] [blame] | 206 | .incompatibleNoRuleOutputsParam(rand.nextBoolean()) |
tomlu | aaf11e9 | 2018-06-02 10:20:16 -0700 | [diff] [blame] | 207 | .incompatibleNoSupportToolsInActionInputs(rand.nextBoolean()) |
cparsons | c750f97 | 2019-06-13 15:52:40 -0700 | [diff] [blame] | 208 | .incompatibleRunShellCommandString(rand.nextBoolean()) |
Gustav Westling | 00ea8fa | 2020-05-01 06:49:01 -0700 | [diff] [blame] | 209 | .incompatibleStringReplaceCount(rand.nextBoolean()) |
Klaus Aehlig | 752ffcc | 2019-10-31 02:49:39 -0700 | [diff] [blame] | 210 | .incompatibleVisibilityPrivateAttributesAtDefinition(rand.nextBoolean()) |
plf | 8efc50e | 2020-02-25 07:11:14 -0800 | [diff] [blame] | 211 | .incompatibleRequireLinkerInputCcApi(rand.nextBoolean()) |
Marwan Tammam | 20c8413 | 2019-06-04 07:27:31 -0700 | [diff] [blame] | 212 | .incompatibleRestrictStringEscapes(rand.nextBoolean()) |
hlopko | 23f052f | 2019-11-15 06:55:09 -0800 | [diff] [blame] | 213 | .incompatibleUseCcConfigureFromRulesCc(rand.nextBoolean()) |
gregce | 3eb7402 | 2020-05-14 10:50:09 -0700 | [diff] [blame] | 214 | .internalStarlarkFlagTestCanary(rand.nextBoolean()) |
adonovan | 553a0e4 | 2020-03-18 13:46:47 -0700 | [diff] [blame] | 215 | .maxComputationSteps(rand.nextLong()) |
adonovan | 40a737c | 2020-03-11 14:32:19 -0700 | [diff] [blame] | 216 | .recordRuleInstantiationCallstack(rand.nextBoolean()) |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 217 | .build(); |
| 218 | } |
| 219 | |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 220 | private static StarlarkSemanticsOptions parseOptions(String... args) throws Exception { |
jcater | e4545fe | 2019-06-19 07:43:02 -0700 | [diff] [blame] | 221 | OptionsParser parser = |
| 222 | OptionsParser.builder() |
| 223 | .optionsClasses(StarlarkSemanticsOptions.class) |
| 224 | .allowResidue(false) |
| 225 | .build(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 226 | parser.parse(Arrays.asList(args)); |
laurentlb | 92c43cd | 2019-02-18 08:27:55 -0800 | [diff] [blame] | 227 | return parser.getOptions(StarlarkSemanticsOptions.class); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 228 | } |
| 229 | } |