diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java | 135 |
1 files changed, 93 insertions, 42 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java b/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java index 60baf97abe..a3e6368bbc 100644 --- a/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java +++ b/src/test/java/com/google/devtools/build/lib/runtime/AllIncompatibleChangesExpansionTest.java @@ -72,8 +72,10 @@ public class AllIncompatibleChangesExpansionTest { @Option( name = "incompatible_A", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -83,8 +85,10 @@ public class AllIncompatibleChangesExpansionTest { @Option( name = "incompatible_B", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -97,8 +101,10 @@ public class AllIncompatibleChangesExpansionTest { public static class ExampleExpansionOptions extends OptionsBase { @Option( name = "incompatible_expX", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "null", @@ -108,7 +114,7 @@ public class AllIncompatibleChangesExpansionTest { public Void incompatibleExpX; /** Dummy comment (linter suppression) */ - public static class YExpansion implements ExpansionFunction { + public static class NoYExpansion implements ExpansionFunction { @Override public ImmutableList<String> getExpansion(IsolatedOptionsData optionsData) { return ImmutableList.of("--noY"); @@ -117,12 +123,14 @@ public class AllIncompatibleChangesExpansionTest { @Option( name = "incompatible_expY", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "null", - expansionFunction = YExpansion.class, + expansionFunction = NoYExpansion.class, help = "Stop using Y" ) public Void incompatibleExpY; @@ -199,6 +207,32 @@ public class AllIncompatibleChangesExpansionTest { assertThat(opts.incompatibleB).isTrue(); // B, without a policy, should have been left alone. } + /** Option with the right prefix, but the wrong metadata tag. */ + public static class IncompatibleChangeTagOption extends OptionsBase { + @Option( + name = "some_option_with_a_tag", + documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + effectTags = {OptionEffectTag.NO_OP}, + defaultValue = "false", + help = "nohelp" + ) + public boolean opt; + } + + @Test + public void incompatibleChangeTagDoesNotTriggerAllIncompatibleChangesCheck() { + try { + OptionsParser.newOptionsParser(ExampleOptions.class, IncompatibleChangeTagOption.class); + } catch (OptionsParser.ConstructionException e) { + fail( + "some_option_with_a_tag should not trigger the expansion, so there should be no checks " + + "on it having the right prefix and metadata tags. Instead, the following exception " + + "was thrown: " + + e.getMessage()); + } + } + // There's no unit test to check that the expansion of --all is sorted. IsolatedOptionsData is not // exposed from OptionsParser, making it difficult to check, and it's not clear that exposing it // would be worth it. @@ -222,8 +256,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadNameOptions extends OptionsBase { @Option( name = "badname", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -240,15 +276,12 @@ public class AllIncompatibleChangesExpansionTest { + "starting with \"incompatible_\""); } - /** - * Option with the right prefix and tag, but the wrong "category." The category is deprecated and - * this test will be deleted when the option field is removed. - */ - public static class BadCategoryOptions extends OptionsBase { + /** Option with the right prefix, but the wrong metadata tag. */ + public static class MissingTriggeredByTagOptions extends OptionsBase { @Option( name = "incompatible_bad", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", help = "nohelp" @@ -257,16 +290,18 @@ public class AllIncompatibleChangesExpansionTest { } @Test - public void badCategory() { - assertBadness(BadCategoryOptions.class, "must have category \"incompatible changes\""); + public void badTag() { + assertBadness( + MissingTriggeredByTagOptions.class, + "must have metadata tag OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES"); } - /** Option with the right prefix and "category," but the wrong metadata tag. */ - public static class BadTagOptions extends OptionsBase { + /** Option with the right prefix, but the wrong metadata tag. */ + public static class MissingIncompatibleTagOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, + metadataTags = {OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES}, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", help = "nohelp" @@ -275,18 +310,20 @@ public class AllIncompatibleChangesExpansionTest { } @Test - public void badTag() { + public void otherBadTag() { assertBadness( - BadTagOptions.class, - "must have metadata tag \"OptionMetadataTag.INCOMPATIBLE_CHANGE\""); + MissingIncompatibleTagOptions.class, + "must have metadata tag OptionMetadataTag.INCOMPATIBLE_CHANGE"); } /** Dummy comment (linter suppression) */ public static class BadTypeOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "0", @@ -304,8 +341,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadHelpOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false" @@ -322,8 +361,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadAbbrevOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -342,8 +383,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadValueHelpOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -362,8 +405,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadConverterOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -382,8 +427,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadAllowMultipleOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "null", @@ -402,8 +449,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadImplicitRequirementsOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", @@ -423,8 +472,10 @@ public class AllIncompatibleChangesExpansionTest { public static class BadOldNameOptions extends OptionsBase { @Option( name = "incompatible_bad", - category = "incompatible changes", - metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, documentationCategory = OptionDocumentationCategory.UNCATEGORIZED, effectTags = {OptionEffectTag.NO_OP}, defaultValue = "false", |