aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
Commit message (Collapse)AuthorAge
* Introduce `--incompatible_disallow_slash_operator` to disable `/` operator.Gravatar laurentlb2018-04-11
| | | | | | | | RELNOTES: The `/` operator is deprecated in favor of `//` (floor integer division). Try the `--incompatible_disallow_slash_operator` flag to ensure your code is forward-compatible. PiperOrigin-RevId: 192430310
* Migrate Info's skylark methods to @SkylarkCallableGravatar cparsons2018-04-10
| | | | | RELNOTES: None PiperOrigin-RevId: 192337555
* Introduce extraPositonals and extraArguments to SkylarkCallable, to have ↵Gravatar cparsons2018-04-09
| | | | | | | | | parity with @SkylarkSignature. This is necessary for several builtin functions that still use @SkylarkSignature, such as string format. These will be migrated in a future CL. RELNOTES: None. PiperOrigin-RevId: 192200282
* Cleanup @SkylarkCallable parameters and their error handling.Gravatar cparsons2018-04-06
| | | | | | | This involves enforcing additional compiletime restrictions on Param ordering and semantics. RELNOTES: None. PiperOrigin-RevId: 191927206
* Fix the definition of Argument in the Skylark specificationGravatar vladmos2018-04-05
| | | | PiperOrigin-RevId: 191717115
* Migrate SkylarkNativeModule methods to use @SkylarkCallable instead of ↵Gravatar cparsons2018-04-04
| | | | | | | | | @SkylarkSignature Most notably, this involves introduction of a new function abstraction, BuiltinMethod, which can wrap a {objc, SkylarkCallable} pair into a BaseFunction for later calling. (This is required due to the current layer of indirection on the end "native" module) RELNOTES: None. PiperOrigin-RevId: 191642467
* Migrate depset.union() and depset.to_list() to SkylarkCallableGravatar cparsons2018-04-04
| | | | | RELNOTES: None. PiperOrigin-RevId: 191641410
* Add option to restrict format strings to %sGravatar brandjon2018-04-04
| | | | | | | This is useful for contexts like ctx.actions.args()'s methods, where %d and %r aren't appropriate placeholders. RELNOTES: None PiperOrigin-RevId: 191629195
* Migrate SkylarkDict and MutableList methods to use @SkylarkCallable instead ↵Gravatar cparsons2018-03-30
| | | | | | | of @SkylarkSignature. RELNOTES: None. PiperOrigin-RevId: 191112273
* Enforce @SkylarkCallable must have a non-empty doc string or explicitly be ↵Gravatar cparsons2018-03-30
| | | | | | | documented=false. RELNOTES: None. PiperOrigin-RevId: 191112140
* Move more tests to test suite (int function, list index, list mutation)Gravatar laurentlb2018-03-28
| | | | | RELNOTES: None. PiperOrigin-RevId: 190823566
* Migrate string tests to Skylark test suite.Gravatar laurentlb2018-03-28
| | | | | RELNOTES: None. PiperOrigin-RevId: 190785580
* Fix incorrect int() exampleGravatar brandjon2018-03-26
| | | | | | | Also add tests for leading "+" in int(<string>) form. RELNOTES: None PiperOrigin-RevId: 190507678
* Automated rollback of commit 316cd7da6f6b003b853ccf7d144f395a9a557400.Gravatar janakr2018-03-26
| | | | | | | | *** Reason for rollback *** Roll-forward with fix (equality and hashcode for relevant classes). Also add a bit more debugging info in case of failure. PiperOrigin-RevId: 190492934
* Bugfixes for int()Gravatar brandjon2018-03-23
| | | | | | | | | | - fix negatives + prefixes - fix boundary cases (min int value) The only remaining relevant differences from Python are that we disallow int() with zero args, we don't allow whitespace in strings, and we take Python 3's view on prohibiting leading 0s when base is 0. RELNOTES: None PiperOrigin-RevId: 190216646
* Victory lap: Remove all code that used to support the three-argument form of ↵Gravatar lberki2018-03-23
| | | | | | | vardef(). RELNOTES: None. PiperOrigin-RevId: 190196933
* Create useSkylarkSemantics for @SkylarkCallable, so annotated methods can ↵Gravatar cparsons2018-03-22
| | | | | | | | | | | specifically get a semantics object This is slightly redundant with useEnvironment, yes (as one can easily obtain the semantics object with Environment), but we intend on restricting useEnvironment so that structField=true methods cannot specify useEnvironment, but *can* specify useSkylarkSemantics. In general, we can also ween off non structField methods to use useSkylarkSemantics instead of useEnvironment in cases where this is feasible. RELNOTES: None. PiperOrigin-RevId: 190082547
* RELNOTES: In int() function, do not auto-detect base if input starts with '0'.Gravatar laurentlb2018-03-22
| | | | PiperOrigin-RevId: 190069001
* Remove the --incompatible_disallow_uncalled_set_constructor flagGravatar vladmos2018-03-22
| | | | | | | | RELNOTES[INC]: The --incompatible_disallow_uncalled_set_constructor flag is no longer available, the `set` constructor` is completely removed from Skylark. Use `depset` instead. PiperOrigin-RevId: 190053331
* Change error messaging of @SkylarkCallable invocations to match ↵Gravatar cparsons2018-03-21
| | | | | | | | | @SkylarkSignature more closely. Also clarify the method representation in these error messages is for the attempted method *call*, not the actual method signature. RELNOTES: None. PiperOrigin-RevId: 189935148
* Add ability to shallow-freeze individual objectsGravatar brandjon2018-03-20
| | | | | | | | | Clarify that the IMMUTABLE Mutability should only be used for deeply immutable things, not tuples. Created a new SHALLOW_IMMUTABLE Mutability for them. Note that the new shallow-freezing functionality marks things as deeply IMMUTABLE without traversing its contents. I.e., it lies, and it is up to the caller to ensure this doesn't cause problems. RELNOTES: NONE PiperOrigin-RevId: 189767422
* @AutoCodec some expressions that show up in Java configured targets.Gravatar janakr2018-03-16
| | | | PiperOrigin-RevId: 189419493
* Optimize GC churn of parameter bindings performed before each user defined ↵Gravatar nharmata2018-03-08
| | | | | | | | | | | | | | | function call. This is the 2nd attempt at this commit. The first attempt (https://github.com/bazelbuild/bazel/commit/f1013485d41efd8503f9d4f937e17d1b4bc91ed3) was rolled back because it introduced the following two bugs: (1) The side effects of Environment#enterScope are relevant: it creates and stores a new Continuation that has a reference to the set currently referenced by 'knownGlobalVariables', and then overwrites the value of the variable. When there are e.g. nested function calls, 'knownGlobalVariables' will be wrong in the Environment used to stage the inner call (see the added test for an example). (2) The finally block in UserDefinedFunction#call assumes the env.enterScope was called. Because of the EvalException (incorrectly) thrown due to (1), this is no longer true. I restructured the code such that (2) isn't possible and I also added a unit test that would have caught the two bugs. In my first attempt, I was doing too much - I was also trying to save the CPU-costs in the env.update call (dispatches to the just-created lexical frame, and calls LexicalFrame#put, which does an unnecessary mutability sanity check, etc) and in doing so completely missed the above bugs. Sorry. RELNOTES: None PiperOrigin-RevId: 188411737
* Allow passing location, ast, and environment to @SkylarkCallable methodsGravatar cparsons2018-03-07
| | | | | RELNOTES: None. PiperOrigin-RevId: 188201686
* Make the builtins registry thread-safeGravatar brandjon2018-03-06
| | | | | | | | | | | | | | It was previously assumed that safety wasn't needed because 1) all builtins should be registered in static initializer blocks, and 2) all retrievals should occur during Skylark evaluation, after static initialization completes. It turns out these assumptions aren't actually true (Who would've thunk it!). SkylarkActionFactory has been observed to be initialized as late as analysis time, and retrievals occur as early as constructing a PackageFactory (when scanning the native module). The failure mode is particularly ugly: Random Skylark method lookups will fail non-deterministically. This change guards against this by making the builtins registry implement a form of freezing. Before freezing, reads and writes are allowed and are synchronized. After freezing, only reads are allowed and they are unsynchronized for performance. BlazeRuntime is responsible for flipping the bit, and for ensuring classes like SkylarkActionFactory run their initialization by that point. Unit tests don't need to worry, since they just stay unfrozen and synchronized throughout. RELNOTES: None PiperOrigin-RevId: 188080136
* Make the distinction between "global frame" and "lexical frame" explicit. As ↵Gravatar nharmata2018-03-01
| | | | | | | a nice consequence, this lets us reduce GC churn since we no longer need to create a frame instance for the lexical frame at a callsite of either a function when the environment is frozen or a builtin function (since builtins cannot modify bindings in their lexical frame). RELNOTES: None PiperOrigin-RevId: 187495787
* Remove --incompatible_load_argument_is_label flagGravatar laurentlb2018-03-01
| | | | | | RELNOTES: Removed flag `--incompatible_load_argument_is_label`. PiperOrigin-RevId: 187479614
* Deletes CODEC fields now that they are no longer needed.Gravatar shahan2018-02-28
| | | | PiperOrigin-RevId: 187397314
* Deprecate and remove several uses of the 'values' map in NativeInfo subclasses.Gravatar cparsons2018-02-28
| | | | | | | | | | These subclasses should be using @SkylarkCallable(structField = true) instead This is a bit of a memory win, as there is now no need to store field information twice. There are still a couple of stragglers that are more difficult, namely ToolchainInfo and DefaultInfo. Their APIs will likely need some more extensive revamping before proceeding. RELNOTES: None. PiperOrigin-RevId: 187364392
* expectThrows has been renamed to assertThrowsGravatar cushon2018-02-24
| | | | | | More information: https://github.com/junit-team/junit5/issues/531 PiperOrigin-RevId: 186900384
* Clarify parser error for load() statementsGravatar brandjon2018-02-22
| | | | | RELNOTES: None PiperOrigin-RevId: 186693205
* Deletes POLYMORPHIC strategy. ObjectCodec now uses runtime type information ↵Gravatar shahan2018-02-20
| | | | | | to select a codec. PiperOrigin-RevId: 186378153
* Remove old flags.Gravatar laurentlb2018-02-16
| | | | | | RELNOTES: Removed flags `--incompatible_checked_arithmetic`, `--incompatible_dict_literal_has_no_duplicates`, `--incompatible_disallow_keyword_only_args`, and ` --incompatible_comprehension_variables_do_not_leak`. PiperOrigin-RevId: 185977740
* Remove unused LineNumberTable.HashLine class.Gravatar laurentlb2018-02-15
| | | | | RELNOTES: None. PiperOrigin-RevId: 185838543
* Environment guarantees determinism when retrieving its bindingsGravatar brandjon2018-02-13
| | | | | | | Added a little javadoc and tests. RELNOTES: None PiperOrigin-RevId: 185569985
* Skylark: SlicingExpression: do not create new nodes for optional expressionsGravatar laurentlb2018-02-12
| | | | | RELNOTES: None. PiperOrigin-RevId: 185353994
* Add debugging helper to Environment.Extension to say why something's unequalGravatar brandjon2018-02-06
| | | | | RELNOTES: None PiperOrigin-RevId: 184649483
* Expose structField callable methods of skylark objects to dir() and str() callsGravatar cparsons2018-02-05
| | | | | RELNOTES: None. PiperOrigin-RevId: 184498836
* Fix string_list_dict values to be skylark lists in all casesGravatar cparsons2018-01-31
| | | | | RELNOTES: None. PiperOrigin-RevId: 184016150
* Add serialization codec for SkylarkImports. This is needed to serialize ↵Gravatar janakr2018-01-18
| | | | | | | | SkylarkAspectLoadingKey. Also add a @VisibleForSerialization annotation to @AutoCodec, since we're going to need to increase serialization visibility a lot here, and clean up some unnecessary modifiers. PiperOrigin-RevId: 182389162
* Fix forbidding of If statements in BUILD filesGravatar brandjon2018-01-17
| | | | | | | | | The bug also permitted For statements in BUILD files so long as they were contained within an If statement (i.e. not at the top level). Also add minor guidance to error messages. RELNOTES: None PiperOrigin-RevId: 182236172
* Codec for Location.Gravatar shahan2018-01-16
| | | | | | * Moves SingletonCodec to third_party. PiperOrigin-RevId: 182143153
* Fix value collision in builtins registryGravatar brandjon2018-01-16
| | | | | | | If two values compared equal (e.g., MethodLibrary#bool and SkylarkAttr#bool), we were dropping one of them in favor of the other. RELNOTES: None PiperOrigin-RevId: 182057611
* Fix testPlusEqualsOnDictGravatar vladmos2018-01-02
| | | | | | | The said test fails if the --incompatible_disallow_dict_plus flag is flipped by default (e.g. in a .bazelrc file) PiperOrigin-RevId: 180553910
* Rename some ClassObject/Provider-related methodsGravatar brandjon2017-12-28
| | | | | | | The terminology "field" is preferred over "key" for the components of a struct or struct-like object. RELNOTES: None PiperOrigin-RevId: 180269374
* Correct typos found by the linter.Gravatar gregce2017-12-20
| | | | PiperOrigin-RevId: 179748374
* Remove the --incompatible_list_plus_equals_inplace flagGravatar vladmos2017-12-08
| | | | | | | | RELNOTES[INC]: The flag --incompatible_list_plus_equals_inplace is removed, its default behavior is preserved. += on lists now always mutates the left hand side. PiperOrigin-RevId: 178359047
* Register builtins with RuntimeGravatar brandjon2017-12-07
| | | | | | | | | | | This covers all builtins in classes that use SkylarkSignatureProcessor#configureSkylarkFunctions. Generally this means things you define with @SkylarkSignature. It is now an error to call configureSkylarkFunctions multiple times for the same class. It should only be called in static initializers. Runtime's static knowledge of builtins has been factored into Runtime.BuiltinRegistry. RELNOTES: None PiperOrigin-RevId: 178295926
* New flag `--incompatible_depset_union` to disable old-style depset merging.Gravatar laurentlb2017-12-07
| | | | | | | RELNOTES: Using `+`, `|` or `.union` on depsets is now deprecated. Please use the new constructor instead (see https://docs.bazel.build/versions/master/skylark/depsets.html). PiperOrigin-RevId: 178262338
* Update tests to use the label-based load() syntax.Gravatar laurentlb2017-11-30
| | | | | RELNOTES: None. PiperOrigin-RevId: 177487913