aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar ccalvarin <ccalvarin@google.com>2017-12-21 16:27:42 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-21 16:29:54 -0800
commit7139420f25f1bfb3fdf3b50b1b260c339c94c20e (patch)
treef3164577f4a4cb0779c7a32cd8ea74fb621617b3 /src/test
parent916c3e4f5233fbf0f39824ee3135e7786b7f7763 (diff)
Open source the option processor tests.
The @Option annotation processor tests verify that the processor generates the correct errors at compile time. RELNOTES: None. PiperOrigin-RevId: 179872837
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/common/options/BUILD5
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/BUILD26
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/OptionProcessorTest.java323
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConverters.java91
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConvertersWithAllowMultiple.java100
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForDocumentedOption.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForInternalOption.java36
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameWithEqualsSign.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/CollectionTypeForAllowMultipleOption.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/ConverterlessOption.java31
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/CorrectCustomConverterForPrimitiveType.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedHiddenCategory.java31
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedInternalCategory.java31
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedUndocumentedCategory.java31
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/DoubleExpansionOption.java43
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/EffectlessOption.java29
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithAllowMultiple.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithImplicitRequirement.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/FinalOptionField.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/FunctionalExpansionOptionWithAllowMultiple.java43
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/HiddenOptionWithCategory.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterType.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterTypeForAllowMultipleOption.java34
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/InternalOptionWithCategory.java32
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/MultipleOptionWithListTypeConverter.java56
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/NamelessOption.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/NonListTypeForAllowMultipleOption.java31
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionInNonOptionBase.java29
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingNoopEffects.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingUnknownEffects.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/PrivateOptionField.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/ProtectedOptionField.java30
-rw-r--r--src/test/java/com/google/devtools/common/options/processor/optiontestsources/StaticOptionField.java30
33 files changed, 1463 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/common/options/BUILD b/src/test/java/com/google/devtools/common/options/BUILD
index fbb837eae9..27ee1c5195 100644
--- a/src/test/java/com/google/devtools/common/options/BUILD
+++ b/src/test/java/com/google/devtools/common/options/BUILD
@@ -1,6 +1,9 @@
filegroup(
name = "srcs",
- srcs = glob(["**"]) + ["//src/test/java/com/google/devtools/common/options/testing:srcs"],
+ srcs = glob(["**"]) + [
+ "//src/test/java/com/google/devtools/common/options/testing:srcs",
+ "//src/test/java/com/google/devtools/common/options/processor:srcs",
+ ],
visibility = ["//src:__pkg__"],
)
diff --git a/src/test/java/com/google/devtools/common/options/processor/BUILD b/src/test/java/com/google/devtools/common/options/processor/BUILD
new file mode 100644
index 0000000000..ba3476732b
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/BUILD
@@ -0,0 +1,26 @@
+filegroup(
+ name = "srcs",
+ srcs = glob(
+ ["**"],
+ ),
+ visibility = ["//src/test/java/com/google/devtools/common/options:__pkg__"],
+)
+
+java_test(
+ name = "OptionProcessorTest",
+ srcs = ["OptionProcessorTest.java"],
+ resources = [":OptionTestFiles"],
+ deps = [
+ "//src/main/java/com/google/devtools/common/options",
+ "//src/main/java/com/google/devtools/common/options/processor:options_preprocessor",
+ "//third_party:compile_testing",
+ "//third_party:guava",
+ "//third_party:junit4",
+ "//third_party:truth",
+ ],
+)
+
+filegroup(
+ name = "OptionTestFiles",
+ srcs = glob(["optiontestsources/*.java"]),
+)
diff --git a/src/test/java/com/google/devtools/common/options/processor/OptionProcessorTest.java b/src/test/java/com/google/devtools/common/options/processor/OptionProcessorTest.java
new file mode 100644
index 0000000000..fc44f83ead
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/OptionProcessorTest.java
@@ -0,0 +1,323 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor;
+
+import static com.google.common.truth.Truth.assertAbout;
+import static com.google.testing.compile.JavaSourceSubjectFactory.javaSource;
+
+import com.google.common.io.Resources;
+import com.google.testing.compile.JavaFileObjects;
+import javax.tools.JavaFileObject;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Unit tests for the compile-time checks in {@link OptionProcessor}. */
+@RunWith(JUnit4.class)
+public class OptionProcessorTest {
+ private static JavaFileObject getFile(String pathToFile) {
+ return JavaFileObjects.forResource(
+ Resources.getResource(
+ "com/google/devtools/common/options/processor/optiontestsources/" + pathToFile));
+ }
+
+ @Test
+ public void optionsInNonOptionBasesAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("OptionInNonOptionBase.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "@Option annotated fields can only be in classes that inherit from OptionsBase.");
+ }
+
+ @Test
+ public void privatelyDeclaredOptionsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("PrivateOptionField.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining("@Option annotated fields should be public.");
+ }
+
+ @Test
+ public void protectedOptionsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("ProtectedOptionField.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining("@Option annotated fields should be public.");
+ }
+
+ @Test
+ public void staticOptionsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("StaticOptionField.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining("@Option annotated fields should not be static.");
+ }
+
+ @Test
+ public void finalOptionsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("FinalOptionField.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining("@Option annotated fields should not be final.");
+ }
+
+ @Test
+ public void namelessOptionsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("NamelessOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining("Option must have an actual name.");
+ }
+
+ @Test
+ public void badNamesAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("BadNameForDocumentedOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Options that are used on the command line as flags must have names made from word "
+ + "characters only.");
+ assertAbout(javaSource())
+ .that(getFile("BadNameWithEqualsSign.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Options that are used on the command line as flags must have names made from word "
+ + "characters only.");
+ }
+
+ @Test
+ public void badNamesForHiddenOptionsPass() {
+ assertAbout(javaSource())
+ .that(getFile("BadNameForInternalOption.java"))
+ .processedWith(new OptionProcessor())
+ .compilesWithoutError();
+ }
+
+ @Test
+ public void deprecatedCategorySaysUndocumented() {
+ assertAbout(javaSource())
+ .that(getFile("DeprecatedUndocumentedCategory.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Documentation level is no longer read from the option category. Category "
+ + "\"undocumented\" is disallowed, see OptionMetadataTags for the relevant tags.");
+ }
+
+ @Test
+ public void deprecatedCategorySaysHidden() {
+ assertAbout(javaSource())
+ .that(getFile("DeprecatedHiddenCategory.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Documentation level is no longer read from the option category. Category "
+ + "\"hidden\" is disallowed, see OptionMetadataTags for the relevant tags.");
+ }
+
+ @Test
+ public void deprecatedCategorySaysInternal() {
+ assertAbout(javaSource())
+ .that(getFile("DeprecatedInternalCategory.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Documentation level is no longer read from the option category. Category "
+ + "\"internal\" is disallowed, see OptionMetadataTags for the relevant tags.");
+ }
+
+ @Test
+ public void optionMustHaveEffectExplicitlyStated() {
+ assertAbout(javaSource())
+ .that(getFile("EffectlessOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option does not list at least one OptionEffectTag. "
+ + "If the option has no effect, please be explicit and add NO_OP. "
+ + "Otherwise, add a tag representing its effect.");
+ }
+
+ @Test
+ public void contradictingEffectTagsAreRejected() {
+ assertAbout(javaSource())
+ .that(getFile("OptionWithContradictingNoopEffects.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option includes NO_OP with other effects. This doesn't make much sense. "
+ + "Please remove NO_OP or the actual effects from the list, whichever is correct.");
+ assertAbout(javaSource())
+ .that(getFile("OptionWithContradictingUnknownEffects.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option includes UNKNOWN with other, known, effects. "
+ + "Please remove UNKNOWN from the list.");
+ }
+
+ @Test
+ public void contradictoryDocumentationCategoryIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("HiddenOptionWithCategory.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option has metadata tag HIDDEN but does not have category UNDOCUMENTED. "
+ + "Please fix.");
+ assertAbout(javaSource())
+ .that(getFile("InternalOptionWithCategory.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option has metadata tag INTERNAL but does not have category UNDOCUMENTED. "
+ + "Please fix.");
+ }
+
+ @Test
+ public void defaultConvertersAreFound() {
+ assertAbout(javaSource())
+ .that(getFile("AllDefaultConverters.java"))
+ .processedWith(new OptionProcessor())
+ .compilesWithoutError();
+ }
+
+ @Test
+ public void defaultConvertersForAllowMultipleOptionsAreFound() {
+ assertAbout(javaSource())
+ .that(getFile("AllDefaultConvertersWithAllowMultiple.java"))
+ .processedWith(new OptionProcessor())
+ .compilesWithoutError();
+ }
+
+ @Test
+ public void converterReturnsListForAllowMultipleIsAllowed() {
+ assertAbout(javaSource())
+ .that(getFile("MultipleOptionWithListTypeConverter.java"))
+ .processedWith(new OptionProcessor())
+ .compilesWithoutError();
+ }
+
+ @Test
+ public void correctCustomConverterForPrimitiveTypePasses() {
+ assertAbout(javaSource())
+ .that(getFile("CorrectCustomConverterForPrimitiveType.java"))
+ .processedWith(new OptionProcessor())
+ .compilesWithoutError();
+ }
+
+ @Test
+ public void converterlessOptionIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("ConverterlessOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Cannot find valid converter for option of type "
+ + "java.util.Map<java.lang.String,java.lang.String>");
+ }
+
+ @Test
+ public void allowMultipleOptionWithCollectionTypeIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("CollectionTypeForAllowMultipleOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option that allows multiple occurrences must be of type java.util.List<E>, "
+ + "but is of type java.util.Collection<java.lang.String>");
+ }
+
+ @Test
+ public void allowMultipleOptionWithNonListTypeIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("NonListTypeForAllowMultipleOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Option that allows multiple occurrences must be of type java.util.List<E>, "
+ + "but is of type java.lang.String");
+ }
+
+ @Test
+ public void optionWithIncorrectConverterIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("IncorrectConverterType.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Type of field (java.lang.String) must be assignable from the converter's return type "
+ + "(java.lang.Integer)");
+ }
+
+ @Test
+ public void allowMultipleOptionWithIncorrectConverterIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("IncorrectConverterTypeForAllowMultipleOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Type of field (java.lang.String) must be assignable from the converter's return type "
+ + "(java.lang.Integer)");
+ }
+
+ @Test
+ public void expansionOptionThatAllowsMultipleIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("ExpansionOptionWithAllowMultiple.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Can't set an option to accumulate multiple values and let it expand to other flags.");
+ }
+
+ @Test
+ public void functionalExpansionOptionThatAllowsMultipleIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("FunctionalExpansionOptionWithAllowMultiple.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Can't set an option to accumulate multiple values and let it expand to other flags.");
+ }
+
+ @Test
+ public void expansionOptionWithImplicitRequirementIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("ExpansionOptionWithImplicitRequirement.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Can't set an option to be both an expansion option and have implicit requirements.");
+ }
+
+ @Test
+ public void expansionOptionThatExpandsInTwoWaysIsRejected() {
+ assertAbout(javaSource())
+ .that(getFile("DoubleExpansionOption.java"))
+ .processedWith(new OptionProcessor())
+ .failsToCompile()
+ .withErrorContaining(
+ "Options cannot expand using both a static expansion list and an expansion function.");
+ }
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConverters.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConverters.java
new file mode 100644
index 0000000000..47c7313220
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConverters.java
@@ -0,0 +1,91 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import com.google.devtools.common.options.TriState;
+import java.time.Duration;
+
+/**
+ * This class should contain all of the types with DEFAULT_CONVERTERS, and each converter should be
+ * found without generating compilation errors.
+ */
+public class AllDefaultConverters extends OptionsBase {
+ @Option(
+ name = "boolean_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean booleanOption;
+
+ @Option(
+ name = "double_option",
+ defaultValue = "42.73",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public double doubleOption;
+
+ @Option(
+ name = "int_option",
+ defaultValue = "42",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public int intOption;
+
+ @Option(
+ name = "long_option",
+ defaultValue = "-5000000000000",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public long longOption;
+
+ @Option(
+ name = "string_option",
+ defaultValue = "strings are strings are strings are strings",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public String stringOption;
+
+ @Option(
+ name = "tri_state_option",
+ defaultValue = "auto",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public TriState triStateOption;
+
+ @Option(
+ name = "duration_option",
+ defaultValue = "3600s",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public Duration durationOption;
+
+ @Option(
+ name = "void_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public Void voidOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConvertersWithAllowMultiple.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConvertersWithAllowMultiple.java
new file mode 100644
index 0000000000..8f26ade062
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/AllDefaultConvertersWithAllowMultiple.java
@@ -0,0 +1,100 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import com.google.devtools.common.options.TriState;
+import java.time.Duration;
+import java.util.List;
+
+/**
+ * This class should contain allowMultiple examples for all of the types with DEFAULT_CONVERTERS,
+ * and each converter should be found without generating compilation errors.
+ */
+public class AllDefaultConvertersWithAllowMultiple extends OptionsBase {
+ @Option(
+ name = "boolean_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Boolean> booleanOption;
+
+ @Option(
+ name = "double_option",
+ defaultValue = "42.73",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Double> doubleOption;
+
+ @Option(
+ name = "int_option",
+ defaultValue = "42",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Integer> intOption;
+
+ @Option(
+ name = "long_option",
+ defaultValue = "-5000000000000",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Long> longOption;
+
+ @Option(
+ name = "string_option",
+ defaultValue = "strings are strings are strings are strings",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<String> stringOption;
+
+ @Option(
+ name = "tri_state_option",
+ defaultValue = "auto",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<TriState> triStateOption;
+
+ @Option(
+ name = "duration_option",
+ defaultValue = "3600s",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Duration> durationOption;
+
+ @Option(
+ name = "void_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<Void> voidOption; // what does this even mean?
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForDocumentedOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForDocumentedOption.java
new file mode 100644
index 0000000000..56f8f04f87
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForDocumentedOption.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class BadNameForDocumentedOption extends OptionsBase {
+ @Option(
+ name = "bad option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForInternalOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForInternalOption.java
new file mode 100644
index 0000000000..afc64c98be
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameForInternalOption.java
@@ -0,0 +1,36 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/**
+ * This example options class has an internal option with a name that isn't accepted on the command
+ * line. Since internal options aren't accepted on the command line anyway, this is accepted and
+ * should not generate a compile-time error.
+ */
+public class BadNameForInternalOption extends OptionsBase {
+ @Option(
+ name = "bad option name.... but it's internal so I don't care",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
+ metadataTags = {OptionMetadataTag.INTERNAL},
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameWithEqualsSign.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameWithEqualsSign.java
new file mode 100644
index 0000000000..601c17d7e6
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/BadNameWithEqualsSign.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class BadNameWithEqualsSign extends OptionsBase {
+ @Option(
+ name = "bad=option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CollectionTypeForAllowMultipleOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CollectionTypeForAllowMultipleOption.java
new file mode 100644
index 0000000000..4dd531296c
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CollectionTypeForAllowMultipleOption.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import java.util.Collection;
+
+/** This example options class should fail to compile. */
+public class CollectionTypeForAllowMultipleOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public Collection<String> badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ConverterlessOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ConverterlessOption.java
new file mode 100644
index 0000000000..c9983b517a
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ConverterlessOption.java
@@ -0,0 +1,31 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import java.util.Map;
+
+/** This example options class should fail to compile. */
+public class ConverterlessOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public Map<String, String> badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CorrectCustomConverterForPrimitiveType.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CorrectCustomConverterForPrimitiveType.java
new file mode 100644
index 0000000000..93c0ebd37d
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/CorrectCustomConverterForPrimitiveType.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Converters;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options specifies a custom converter that passes the compile-time checks. */
+public class CorrectCustomConverterForPrimitiveType extends OptionsBase {
+ @Option(
+ name = "option_with_primitive_type_and_correct_converter",
+ defaultValue = "5",
+ converter = Converters.RangeConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public int intInARange;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedHiddenCategory.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedHiddenCategory.java
new file mode 100644
index 0000000000..7c891849fe
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedHiddenCategory.java
@@ -0,0 +1,31 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class DeprecatedHiddenCategory extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ category = "hidden",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedInternalCategory.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedInternalCategory.java
new file mode 100644
index 0000000000..04a1aa2c7f
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedInternalCategory.java
@@ -0,0 +1,31 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class DeprecatedInternalCategory extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ category = "internal",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedUndocumentedCategory.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedUndocumentedCategory.java
new file mode 100644
index 0000000000..919fb77037
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DeprecatedUndocumentedCategory.java
@@ -0,0 +1,31 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class DeprecatedUndocumentedCategory extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ category = "undocumented",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DoubleExpansionOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DoubleExpansionOption.java
new file mode 100644
index 0000000000..6b9b1563b3
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/DoubleExpansionOption.java
@@ -0,0 +1,43 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.common.options.ExpansionContext;
+import com.google.devtools.common.options.ExpansionFunction;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class DoubleExpansionOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP,
+ expansion = "--foo=bar",
+ expansionFunction = FooBarExpansion.class
+ )
+ public Void badOption;
+
+ /** Dummy expansion class for the illegal option. */
+ public static class FooBarExpansion implements ExpansionFunction {
+ @Override
+ public ImmutableList<String> getExpansion(ExpansionContext context) {
+ return ImmutableList.of("--foo", "--bar");
+ }
+ }
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/EffectlessOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/EffectlessOption.java
new file mode 100644
index 0000000000..a2481281f8
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/EffectlessOption.java
@@ -0,0 +1,29 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class EffectlessOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithAllowMultiple.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithAllowMultiple.java
new file mode 100644
index 0000000000..1f6c1352d8
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithAllowMultiple.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class ExpansionOptionWithAllowMultiple extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP,
+ expansion = "--foo=bar",
+ allowMultiple = true
+ )
+ public Void badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithImplicitRequirement.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithImplicitRequirement.java
new file mode 100644
index 0000000000..66ea277e8b
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ExpansionOptionWithImplicitRequirement.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class ExpansionOptionWithImplicitRequirement extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP,
+ expansion = "--foo=bar",
+ implicitRequirements = "--nobaz"
+ )
+ public Void badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FinalOptionField.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FinalOptionField.java
new file mode 100644
index 0000000000..0182e3fed4
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FinalOptionField.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class FinalOptionField extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP
+ )
+ public final boolean badOption = false;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FunctionalExpansionOptionWithAllowMultiple.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FunctionalExpansionOptionWithAllowMultiple.java
new file mode 100644
index 0000000000..87489d21b5
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/FunctionalExpansionOptionWithAllowMultiple.java
@@ -0,0 +1,43 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.common.options.ExpansionContext;
+import com.google.devtools.common.options.ExpansionFunction;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class FunctionalExpansionOptionWithAllowMultiple extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "null",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP,
+ expansionFunction = FooBarExpansion.class,
+ allowMultiple = true
+ )
+ public Void badOption;
+
+ /** Dummy expansion class for the illegal option. */
+ public static class FooBarExpansion implements ExpansionFunction {
+ @Override
+ public ImmutableList<String> getExpansion(ExpansionContext context) {
+ return ImmutableList.of("--foo", "--bar");
+ }
+ }
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/HiddenOptionWithCategory.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/HiddenOptionWithCategory.java
new file mode 100644
index 0000000000..6d31eeef76
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/HiddenOptionWithCategory.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class HiddenOptionWithCategory extends OptionsBase {
+ @Option(
+ name = "hidden_option_wants_to_be_documented",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
+ effectTags = OptionEffectTag.NO_OP,
+ metadataTags = OptionMetadataTag.HIDDEN
+ )
+ public boolean hiddenOptionWithDocumentation;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterType.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterType.java
new file mode 100644
index 0000000000..130f9d3b33
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterType.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Converters.IntegerConverter;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class IncorrectConverterType extends OptionsBase {
+ @Option(
+ name = "option_has_incorrect_converter_for_type",
+ defaultValue = "strings are strings, not integers",
+ converter = IntegerConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public String badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterTypeForAllowMultipleOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterTypeForAllowMultipleOption.java
new file mode 100644
index 0000000000..99baab5c7a
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/IncorrectConverterTypeForAllowMultipleOption.java
@@ -0,0 +1,34 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Converters.IntegerConverter;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import java.util.List;
+
+/** This example options class should fail to compile. */
+public class IncorrectConverterTypeForAllowMultipleOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ converter = IntegerConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<String> badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/InternalOptionWithCategory.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/InternalOptionWithCategory.java
new file mode 100644
index 0000000000..d9f5f6659c
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/InternalOptionWithCategory.java
@@ -0,0 +1,32 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionMetadataTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class InternalOptionWithCategory extends OptionsBase {
+ @Option(
+ name = "internal_option_wants_to_be_documented",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.BAZEL_CLIENT_OPTIONS,
+ effectTags = OptionEffectTag.NO_OP,
+ metadataTags = OptionMetadataTag.INTERNAL
+ )
+ public boolean internalOptionWithDocumentation;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/MultipleOptionWithListTypeConverter.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/MultipleOptionWithListTypeConverter.java
new file mode 100644
index 0000000000..e44ca35813
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/MultipleOptionWithListTypeConverter.java
@@ -0,0 +1,56 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+import java.util.List;
+
+/**
+ * This example options class checks multiple combinations of list-type options that should all
+ * successfully compile.
+ */
+public class MultipleOptionWithListTypeConverter extends OptionsBase {
+ @Option(
+ name = "multiple_strings_multiple_times_grouped",
+ defaultValue = "null",
+ converter = CommaSeparatedOptionListConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<List<String>> multipleStringsKeptInGroups;
+
+ @Option(
+ name = "multiple_strings_multiple_times_concatenated",
+ defaultValue = "null",
+ converter = CommaSeparatedOptionListConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public List<String> multipleStringsConcatenated; // Not List<List<String>>
+
+ @Option(
+ name = "multiple_strings_single_time",
+ defaultValue = "a,b,c",
+ converter = CommaSeparatedOptionListConverter.class,
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public List<String> multipleStringsSingleMention;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NamelessOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NamelessOption.java
new file mode 100644
index 0000000000..faffcda0c0
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NamelessOption.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class NamelessOption extends OptionsBase {
+ @Option(
+ name = "",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP}
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NonListTypeForAllowMultipleOption.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NonListTypeForAllowMultipleOption.java
new file mode 100644
index 0000000000..711737d623
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/NonListTypeForAllowMultipleOption.java
@@ -0,0 +1,31 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class NonListTypeForAllowMultipleOption extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP},
+ allowMultiple = true
+ )
+ public String badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionInNonOptionBase.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionInNonOptionBase.java
new file mode 100644
index 0000000000..a513c86132
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionInNonOptionBase.java
@@ -0,0 +1,29 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+
+/** This example options class should fail to compile. */
+public class OptionInNonOptionBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP
+ )
+ public boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingNoopEffects.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingNoopEffects.java
new file mode 100644
index 0000000000..22d4399411
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingNoopEffects.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class OptionWithContradictingNoopEffects extends OptionsBase {
+ @Option(
+ name = "affect_terminal_without_affecting_anything",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.NO_OP, OptionEffectTag.TERMINAL_OUTPUT}
+ )
+ public boolean effectAndNoopEffect;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingUnknownEffects.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingUnknownEffects.java
new file mode 100644
index 0000000000..8be0d8d945
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/OptionWithContradictingUnknownEffects.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class OptionWithContradictingUnknownEffects extends OptionsBase {
+ @Option(
+ name = "affect_output_is_also_unknown",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = {OptionEffectTag.UNKNOWN, OptionEffectTag.TERMINAL_OUTPUT}
+ )
+ public boolean effectAndUnknownEffect;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/PrivateOptionField.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/PrivateOptionField.java
new file mode 100644
index 0000000000..55e71f3f4f
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/PrivateOptionField.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class PrivateOptionField extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP
+ )
+ private boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ProtectedOptionField.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ProtectedOptionField.java
new file mode 100644
index 0000000000..423e30b179
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/ProtectedOptionField.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class ProtectedOptionField extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP
+ )
+ boolean badOption;
+}
diff --git a/src/test/java/com/google/devtools/common/options/processor/optiontestsources/StaticOptionField.java b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/StaticOptionField.java
new file mode 100644
index 0000000000..8c76419e2b
--- /dev/null
+++ b/src/test/java/com/google/devtools/common/options/processor/optiontestsources/StaticOptionField.java
@@ -0,0 +1,30 @@
+// Copyright 2017 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.common.options.processor.optiontestsources;
+
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionDocumentationCategory;
+import com.google.devtools.common.options.OptionEffectTag;
+import com.google.devtools.common.options.OptionsBase;
+
+/** This example options class should fail to compile. */
+public class StaticOptionField extends OptionsBase {
+ @Option(
+ name = "bad_option",
+ defaultValue = "true",
+ documentationCategory = OptionDocumentationCategory.UNCATEGORIZED,
+ effectTags = OptionEffectTag.NO_OP
+ )
+ public static boolean badOption;
+}