aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/common
Commit message (Collapse)AuthorAge
* Refactoring: OptionsParser now uses the visitor pattern to iterate over ↵Gravatar fwe2017-08-28
| | | | | | | | | Blaze options. This change is in preparation for unknown commit which also needs to iterate over all options, but has to execute a different action than getOptionsCompletion(). As a result, applying the visitor patterns helps to avoid duplicate iteration code. PiperOrigin-RevId: 166515117
* Check at compile time that all options are declared public, and are ↵Gravatar ccalvarin2017-08-24
| | | | | | | | non-final and non-static. Remove the now redundant check in the testing framework, as the cases being tested no longer compile. Keep tests that check the contents of the OptionsBase as a whole, however, as this is still not being tested at compile time. PiperOrigin-RevId: 166239209
* Add OptionDefinition layer between the @Option annotation and its fields and ↵Gravatar ccalvarin2017-08-22
| | | | | | | | | | | the options parser. Removes any direct reads of the annotation outside of OptionDefinition. This allows for fewer manual checks for the annotation's existence, unifies error wording, and paves the way for potentially generifying the OptionsParser to accept different @Option-equivalent annotations. Also allows for cleanup of duplicate code by giving @Option-specific operations a clear home, such as sorts and default logic. In followup changes, we can eliminate some unnecessarily complex caching by instead memoizing values in the OptionDefinition. This will have the positive side effect of making sure reads come from the cached values. RELNOTES: None. PiperOrigin-RevId: 166019075
* Fix expansion option output formatting in html outputGravatar ccalvarin2017-08-18
| | | | | | Like the terminal output, there was some discrepancy between the expansion function and static expansion behavior. Also adds html usage output tests. PiperOrigin-RevId: 165584454
* Fix terminal output expansion flag spacing & add implicit requirements.Gravatar ccalvarin2017-08-17
| | | | | | | Add unit tests for individual flag usage output. Also move around some of the sample expansion function test options, which could be used more widely, to minimize recreating the boilerplate samples. RELNOTES: None. PiperOrigin-RevId: 165478776
* Use cached values for option converter types.Gravatar ccalvarin2017-08-16
| | | | | | This requires us to have OptionsData for all usage messages, since static functionality is being removed, but this should already have been the case. It was added as an optional argument when the expansion function feature was added, but there is actually no reason not to require it, as the public interface for usage text was already computing the optionsData anyway. PiperOrigin-RevId: 165386893
* Accept expansion flags expanding to expansion flags in invocation policy.Gravatar ccalvarin2017-08-03
| | | | | | | Fix bug where a null value in the expansion text lead to a NullPointerException. RELNOTES: None. PiperOrigin-RevId: 164061496
* Move the DurationConverter to the common.options packageGravatar ulfjack2017-07-24
| | | | | | | Also change it to java.time.Duration, rather than Jodatime. Now that we're on Java 8, we no longer need Jodatime. PiperOrigin-RevId: 162917526
* Add test framework for OptionsBase classes and their Converters.Gravatar mstaib2017-07-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because OptionsBase implements equals() as a final method, subclasses can only add fields in certain ways for OptionsBase to properly obey equals() semantics. Specifically, all fields must be public and @Option annotated. The OptionsTester checks for these two things. Additionally, Converters must make sure to always return equals() values on equals() (or equivalent) input. The OptionsTester includes a check that all Converters named by the OptionsBase subclass being tested have matching ConverterTesters, and if valid default values are specified (i.e., on Options which are not multi-valued or default null), that these defaults are among the values tested by the ConverterTesters. The ConverterTesters themselves are wrapped EqualsTesters, testing that the output of a Converter obeys equals() as expected for the same input (or equivalent ones), and is consistent across calls to the same Converter instance or different Converter instances. Between these two, OptionsBase subclasses can have reasonable certainty that two instances of themselves which were parsed equally - or underwent equivalent transformations - will be equal. This does not actually test any OptionsBase subclasses or Converter implementations; it merely adds a framework. Future changes will cover automatically testing all of the OptionsBase subclasses in a RuleClassProvider, but naturally, this requires writing test data for each Converter in the Bazel codebase first. RELNOTES: None. PiperOrigin-RevId: 162522445
* Split invocation policy from the optionsparser target.Gravatar ccalvarin2017-07-19
| | | | | | //src/main/java/com/google/devtools/common/options:options is now free of bazel protos, once again. PiperOrigin-RevId: 162385612
* Make the @Option annotation depend on the java version of the tagging enums.Gravatar ccalvarin2017-07-18
| | | | | | | The option filters proto dependency can be removed from the OptionsParser. This is in response to option parser users that want to avoid the bazel-internal proto file in their dependencies. RELNOTES: None. PiperOrigin-RevId: 162249778
* Add the option filter enums in java, with equivalence check.Gravatar ccalvarin2017-07-17
| | | | | | | | | | In order to break out the proto dependency of the OptionsParser, add a java-only enum that users of the options parser can depend on, instead of requiring the dependency on the protobuf. The protocol buffer definition is kept in order to be used for command line reporting in the BEP, so a test is added to make sure that the two are kept in sync. Also add some clearer guidance for how to go about selecting, and adding, option categories and tags. Migrating the current uses of the proto enum to this one will happen in a follow-up change. PiperOrigin-RevId: 161971077
* Fold OptionUsageRestrictions into OptionDocumentationCategory and ↵Gravatar ccalvarin2017-07-11
| | | | | | | | | | OptionMetadataTags. These are similar, no need to have both fields. Removing the "DOCUMENTED" default, the absence of UNDOCUMENTED will be used instead. Since requiring a documentation category for undocumented options doesn't make sense, list that as one of the OptionDocumentationCategories, but list HIDDEN and INTERNAL as part of OptionMetadata. These options should list UNDOCUMENTED as their category. PiperOrigin-RevId: 161515674
* Enforce the new category and effect tags.Gravatar ccalvarin2017-07-03
| | | | | | | | | | All options need to explicitly list their category and effect. If they are uncategorized, this makes the lack of information obvious. Remove defaults from the annotation to enforce this. Also enforce the sanity check that no option should have UNKNOWN or NO_OP effects listed with other effect tags. Includes some last default sets for options I missed in the previous mass-setting change, and some that were added since. PiperOrigin-RevId: 160641861
* Explicitly state the default options categories for options used in blaze ↵Gravatar ccalvarin2017-06-29
| | | | | | | | testing. Unlike in the production flags, these flags are only used for internal testing. Tagged them as NO_OP instead of the default UNKNOWN to make it clear that we do not need these to become properly tagged. PiperOrigin-RevId: 160526472
* Allow expansion flags to have values.Gravatar Googler2017-06-28
| | | | | | | This lets us change what it expands based on the argument passed to the flag. RELNOTES: Allows flags that expand to take values. PiperOrigin-RevId: 160298412
* Move InvocationPolicy to the options parser package.Gravatar ccalvarin2017-06-09
| | | | | | | | | | | | | | It was originally included in runtime due to external dependencies, and a desire to keep the options parser a general options library. These dependencies have been or will be removed, and there are plenty of other general flag libraries. InvocationPolicy is fundamentally acting on the properties of this specific OptionsParser and needs proper access to it for the proper solution to a number of existing bugs, which means having access to things that should be package private. PiperOrigin-RevId: 158523111
* Use ImmutableList for Option expansion functionsGravatar Googler2017-06-08
| | | | | RELNOTES: None PiperOrigin-RevId: 158279811
* Require that flags with static expansions be of Void type.Gravatar ccalvarin2017-06-07
| | | | | | | The type was ignored, and it was expected that all expansion flags had no value of their own, but was not checked. PiperOrigin-RevId: 158261788
* Internal changeGravatar Googler2017-06-05
| | | | PiperOrigin-RevId: 157878648
* Remove support of --no_ prefix for boolean flags.Gravatar ccalvarin2017-06-01
| | | | | | | | The no_ prefix was initially undocumented, but its support has over time lead to a number of inconsistencies. RELNOTES: --no_ prefix no longer recognized. PiperOrigin-RevId: 157631435
* Migrate tests to Truth.Gravatar lberki2017-05-29
| | | | | | RELNOTES: None. PiperOrigin-RevId: 157378037
* Fixes incorrectly-ordered arguments to calls to assertEqualsGravatar Googler2017-05-19
| | | | | | | | | | | | | | | [] This change has been automatically generated by an Error Prone check that detects incorrect argument ordering on calls to assertEquals-style methods. See [] Cleanup change automatically generated by javacflume/refactory Refactoring: third_party/java_src/error_prone/project/core/src/main/java/com/google/errorprone/bugpatterns/argumentselectiondefects:AssertEqualsArgumentOrderChecker_refactoring Tested: TAP --sample for global presubmit queue [] PiperOrigin-RevId: 156539781
* Add a way for options classes to mark that they are skyframe-friendlyGravatar brandjon2017-04-27
| | | | | | | You can now use the annotation @UsesOnlyCoreTypes on a subclass of OptionsBase, to indicate that all of its options' types are restricted to a whitelist of immutable and serializable types. Subclasses of the annotated class must also follow the same restriction. RELNOTES: None PiperOrigin-RevId: 154328920
* Don't hard remove --no_, give a warning first.Gravatar ccalvarin2017-04-20
| | | | PiperOrigin-RevId: 153610163
* Add a way of constructing OptionsBase subclass instances from mapsGravatar brandjon2017-04-20
| | | | | | | Added toMap()/fromMap() to OptionsParser, and moved the implementation of OptionsBase#asMap away from OptionsParserImpl. RELNOTES: None PiperOrigin-RevId: 153602479
* Deprecate use of option category to describe documentation level / usage ↵Gravatar ccalvarin2017-04-19
| | | | | | | | restrictions. Prevent the old category strings "undocumented," "hidden," or "internal" from being used as categories, to prevent developers from relying on deprecated behavior. PiperOrigin-RevId: 153525499
* Add ordering semantics for cached options dataGravatar brandjon2017-04-18
| | | | | | | This lets us easily get all options classes of a parser, or all fields of those options classes, in a deterministic way. RELNOTES: None PiperOrigin-RevId: 153376699
* Remove the overloading of option category to cover documentation level.Gravatar ccalvarin2017-04-18
| | | | | | | | This prevents having to parse the category, and allows the category to potentially be used in the future for information about all options, included undocumented, hidden, or internal options. Also rename DocumentationLevel to OptionUsageRestrictions, since INTERNAL was not really documentation related. PiperOrigin-RevId: 153367769
* Refactor options tests into a new fileGravatar brandjon2017-04-18
| | | | | | | | | | | OptionsParserTest is kind of massive. This CL splits off tests that only concern IsolatedOptionsData. For example, tests that deal with malformed option specifications, but not string parsing, would go here. A followup CL will add tests of IsolatedOptionsData's accessor methods. Also added a unit test for the warning added by https://github.com/bazelbuild/bazel/commit/e11775c2394fc48ac7fe5b632b47ae952dd552b4. RELNOTES: None PiperOrigin-RevId: 153346363
* Remove --no_ support.Gravatar ccalvarin2017-04-07
| | | | | --no_ prefixes for boolean flags are deprecated. Error out nicely if --no_ is supplied. PiperOrigin-RevId: 152434290
* Add new exception for wrapping parser construction failuresGravatar brandjon2017-04-03
| | | | | | | | | | The exception is unchecked. The reasoning is that errors during parser construction should not occur, and when they do occur it is an internal error like a failed assertion. This allows casual uses of the options parser to stay oblivious to the possibility of failures, consistent with how DuplicateOptionDeclarationException is currently [not] handled. At the same time, the dispatcher can catch the exception to fail gracefully (by printing to stdout instead of a log file) when parser construction fails for any reason. RELNOTES: None PiperOrigin-RevId: 151839620
* Watch for --no and --no_ flag name conflicts.Gravatar ccalvarin2017-03-31
| | | | | | | | | Prevent OptionsBases with conflicting names due to --no boolean flag aliases to successfully combine into parser. Also remove the comment about --no_ not being documented, since it has been documented since Bazel was open-sourced. PiperOrigin-RevId: 151738453
* Add expansion functions to options parserGravatar Jon Brandvein2017-03-22
| | | | | | | | | | | | This provides a way to programmatically define expansions of options based on what other options are defined for the parser. In particular, it will be used for the --incompatible_* changes mechanism, to turn on all incompatible change flags. Expansion functions are specified in the @Option annotation, similar to converters. They are computed when an OptionsParser is constructed, and inspect a preliminary version of its OptionsData to determine the expansion result. This is then cached in the final OptionsData used by the parser. Expansion information for usage strings is available, but only when the usage strings are obtained via the parser. -- PiperOrigin-RevId: 150817553 MOS_MIGRATED_REVID=150817553
* Create "internal" category of command-line options.Gravatar Michael Staib2017-03-20
| | | | | | | | | | | | | | | | | | | | This is intended to be used for "flags" which should never appear on the command line - things like configuration distinguishers, which are used internally and must be part of the build options, but should always be set to their default value at the top level. This is already a convention within Bazel, but doesn't actually work the way Bazel expects - flags with spaces can be set by simply escaping or quoting the spaces so that word splitting will not break on them. This means they can also be matched by config_settings, which pass a single string. Forbidding the parser from matching these flags solves both of these unintended cases. Existing cases like this have also been converted to internal. -- PiperOrigin-RevId: 150497246 MOS_MIGRATED_REVID=150497246
* Fix the OptionsParser to deal with CRLF line endings.Gravatar Googler2017-01-25
| | | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/2416 -- PiperOrigin-RevId: 145595491 MOS_MIGRATED_REVID=145595491
* Enable parameter file support for excessively long commandlines.Gravatar Googler2017-01-25
| | | | | | -- PiperOrigin-RevId: 145473123 MOS_MIGRATED_REVID=145473123
* Global cleanup change.Gravatar Eddie Aftandilian2017-01-20
| | | | | | -- PiperOrigin-RevId: 145059124 MOS_MIGRATED_REVID=145059124
* Add a necessary dependency to options_test.Gravatar Lukacs Berki2016-08-04
| | | | | -- MOS_MIGRATED_REVID=129316675
* Global cleanup change.Gravatar Googler2016-08-03
| | | | | -- MOS_MIGRATED_REVID=129226221
* Add all the sources to //:srcs filegroup and add a check to detectGravatar Damien Martin-Guillerez2016-07-01
| | | | | | | | | | | missing file to it. We need to activate this check on presubmits -- Change-Id: Ia95e92d3816ce92bb69bc0e2cf56e9c60b68d970 Reviewed-on: https://bazel-review.googlesource.com/#/c/3949/ MOS_MIGRATED_REVID=126404792
* Delete the defaultMultipleValue field from options and refactor the logic ↵Gravatar Luis Fernando Pino Duque2016-04-20
| | | | | | | | | | | | | | | | for retrieving the default values of options. The field defaultMultipleValue was introduced in commit 51a491b89a9cd5f15c9a093a5693bc37e696e6e1 to allow defining a default value for options that set allowMultiple. However due to the limitations of the optionsParser end up being not useful since we cannot guarantee that an option that allows multiple has a converter that returns a list of values. Thus this CL deletes code that may confuse even more and clarifies the mechanism that the options currently use to obtain their default values. -- MOS_MIGRATED_REVID=120317261
* Add sanity unit test for options classes that are subclasses of other ↵Gravatar Nathan Harmata2016-04-19
| | | | | | | options classes. -- MOS_MIGRATED_REVID=120125572
* Add a new field to options called defaultMultipleValue which enables setting ↵Gravatar Luis Fernando Pino Duque2016-03-21
| | | | | | | | | | | | | | | default values for flags whose allowMultiple is true. The behavior is the following: - If allowMultiple is false then behave as previously. - Otherwise for retrieving the default we now look at defaultMultipleValue instead of defaultValue and in the process it will apply the converter to each element. If no defaultMultipleValue is specified then the default value will be an empty list. -- MOS_MIGRATED_REVID=117558645
* Refactoring of the OptionsParser implementation to allow overriding the ↵Gravatar Luis Fernando Pino Duque2016-02-24
| | | | | | | | | value of an option with null. Currently it returns the original default value if the new value is null. -- MOS_MIGRATED_REVID=115442253
* Set test_class for java_test test target where it is neededGravatar Damien Martin-Guillerez2016-01-19
| | | | | | | | | This make those test target compatible with --nolegacy_bazel_java_test. -- Change-Id: I2316c9aa53327b417ecce5fd5dab95ec726da11d Reviewed-on: https://bazel-review.googlesource.com/#/c/2690 MOS_MIGRATED_REVID=112446514
* Adds support for invocation policy to the canonicalize-flags command.Gravatar Alex Humesky2016-01-15
| | | | | -- MOS_MIGRATED_REVID=112267123
* Deprecation warnings are no longer printed for flags specified using their ↵Gravatar Alex Humesky2015-11-12
| | | | | | | old name. -- MOS_MIGRATED_REVID=107611961
* Split off more BUILD files.Gravatar Han-Wen Nienhuys2015-10-30
| | | | | -- MOS_MIGRATED_REVID=106597904
* Adds a little test to the options parser test to ensure that warnings are notGravatar Alex Humesky2015-10-28
| | | | | | | created for flags that were renamed, but which were specified on the command line using their new name. -- MOS_MIGRATED_REVID=106458953