Skip to content

Commit

Permalink
Rename to --incompatible_enforce_starlark_utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Jan 16, 2025
1 parent fe08808 commit 7de83ec
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ public Converter() {
}

@Option(
name = "incompatible_enforce_utf8",
name = "incompatible_enforce_starlark_utf8",
defaultValue = "warning",
converter = Utf8EnforcementMode.Converter.class,
documentationCategory = OptionDocumentationCategory.INPUT_STRICTNESS,
Expand All @@ -820,7 +820,7 @@ public Converter() {
"If enabled (or set to 'error'), fail if Starlark files are not UTF-8 encoded."
+ " If set to 'warning', emits a warning instead. Even if set to 'off', Bazel will"
+ " assume that Starlark files are UTF-8 encoded.")
public Utf8EnforcementMode incompatibleEnforceUtf8;
public Utf8EnforcementMode incompatibleEnforceStarlarkUtf8;

/**
* An interner to reduce the number of StarlarkSemantics instances. A single Blaze instance should
Expand Down Expand Up @@ -890,7 +890,7 @@ public StarlarkSemantics toStarlarkSemantics() {
.setBool(StarlarkSemantics.PRINT_TEST_MARKER, internalStarlarkFlagTestCanary)
.setBool(
INCOMPATIBLE_DO_NOT_SPLIT_LINKING_CMDLINE, incompatibleDoNotSplitLinkingCmdline)
.set(INCOMPATIBLE_ENFORCE_UTF8, incompatibleEnforceUtf8)
.set(INCOMPATIBLE_ENFORCE_STARLARK_UTF8, incompatibleEnforceStarlarkUtf8)
.setBool(
INCOMPATIBLE_USE_CC_CONFIGURE_FROM_RULES_CC, incompatibleUseCcConfigureFromRulesCc)
.setBool(
Expand Down Expand Up @@ -1055,8 +1055,10 @@ public StarlarkSemantics toStarlarkSemantics() {
new StarlarkSemantics.Key<>("repositories_without_autoloads", ImmutableList.of());
public static final StarlarkSemantics.Key<List<String>> EXPERIMENTAL_BUILTINS_INJECTION_OVERRIDE =
new StarlarkSemantics.Key<>("experimental_builtins_injection_override", ImmutableList.of());
public static final StarlarkSemantics.Key<Utf8EnforcementMode> INCOMPATIBLE_ENFORCE_UTF8 =
new StarlarkSemantics.Key<>("incompatible_enforce_utf8", Utf8EnforcementMode.OFF);
public static final StarlarkSemantics.Key<Utf8EnforcementMode>
INCOMPATIBLE_ENFORCE_STARLARK_UTF8 =
new StarlarkSemantics.Key<>(
"incompatible_enforce_starlark_utf8", Utf8EnforcementMode.OFF);
public static final StarlarkSemantics.Key<Long> MAX_COMPUTATION_STEPS =
new StarlarkSemantics.Key<>("max_computation_steps", 0L);
public static final StarlarkSemantics.Key<Integer> NESTED_SET_DEPTH_LIMIT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static BzlCompileValue computeInline(
return null;
}

switch (semantics.get(BuildLanguageOptions.INCOMPATIBLE_ENFORCE_UTF8)) {
switch (semantics.get(BuildLanguageOptions.INCOMPATIBLE_ENFORCE_STARLARK_UTF8)) {
case OFF -> {}
case WARNING -> {
if (!Utf8.isWellFormed(bytes)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private static BuildLanguageOptions buildRandomOptions(Random rand) throws Excep
"--incompatible_disallow_struct_provider_syntax=" + rand.nextBoolean(),
"--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean(),
"--incompatible_enable_deprecated_label_apis=" + rand.nextBoolean(),
"--incompatible_enforce_utf8="
"--incompatible_enforce_starlark_utf8="
+ BuildLanguageOptions.Utf8EnforcementMode.values()[
rand.nextInt(BuildLanguageOptions.Utf8EnforcementMode.values().length)]
.toString()
Expand Down Expand Up @@ -198,7 +198,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.setBool(BuildLanguageOptions.INCOMPATIBLE_DO_NOT_SPLIT_LINKING_CMDLINE, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_ENABLE_DEPRECATED_LABEL_APIS, rand.nextBoolean())
.set(
BuildLanguageOptions.INCOMPATIBLE_ENFORCE_UTF8,
BuildLanguageOptions.INCOMPATIBLE_ENFORCE_STARLARK_UTF8,
BuildLanguageOptions.Utf8EnforcementMode.values()[
rand.nextInt(BuildLanguageOptions.Utf8EnforcementMode.values().length)])
.setBool(BuildLanguageOptions.INCOMPATIBLE_LOCATIONS_PREFERS_EXECUTABLE, rand.nextBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void testBigIntegerLiterals() throws Exception {

@Test
public void testInvalidUtf8_enforcementOff() throws Exception {
setBuildLanguageOptions("--noincompatible_enforce_utf8");
setBuildLanguageOptions("--noincompatible_enforce_starlark_utf8");

scratch.file("pkg/BUILD");
scratch.file("pkg/foo.bzl", new byte[] {'#', ' ', (byte) 0x80});
Expand All @@ -186,7 +186,7 @@ public void testInvalidUtf8_enforcementOff() throws Exception {

@Test
public void testInvalidUtf8_enforcementWarning() throws Exception {
setBuildLanguageOptions("--incompatible_enforce_utf8=warning");
setBuildLanguageOptions("--incompatible_enforce_starlark_utf8=warning");

scratch.file("pkg/BUILD");
scratch.file("pkg/foo.bzl", new byte[] {'#', ' ', (byte) 0x80});
Expand All @@ -202,7 +202,7 @@ public void testInvalidUtf8_enforcementWarning() throws Exception {

@Test
public void testInvalidUtf8_enforcementError() throws Exception {
setBuildLanguageOptions("--incompatible_enforce_utf8");
setBuildLanguageOptions("--incompatible_enforce_starlark_utf8");

scratch.file("pkg/BUILD");
scratch.file("pkg/foo.bzl", new byte[] {'#', ' ', (byte) 0x80});
Expand Down

0 comments on commit 7de83ec

Please sign in to comment.