Commit Graph

26 Commits

Author SHA1 Message Date
c-parsons a2ec47917b
fix a number of warnings found by Starlark analyzer (#114) 2019-02-22 17:44:48 -05:00
c-parsons a35b13a1c9
analysistest API for retrieval of actions registered by target under test 2019-02-20 15:32:47 -05:00
c-parsons baaef76aaa
Add analysis_test rule
Targets of this rule verify that targets can be analyzed successfully.
This is similar to build_test, except no actual action execution of
the underlying targets occur. analysis_test essentially verifies that
`bazel build [targets] --nobuild` passes.
2019-02-19 15:16:36 -05:00
c-parsons 6bb8994a03
Add analysis-test test framework (#110)
This framework allows for easy creation of unittest-like tests to make assertions
on the provider-values returned by real targets.
2019-02-14 16:54:42 -05:00
c-parsons 7a536d396b
Add basic shell testing for unittest.bzl (#108) 2019-02-11 17:18:56 -05:00
Tony Allevato 6741f73322 Add `types.is_depset`. (#105) 2019-02-08 18:37:26 +01:00
Thomas Van Lenten d3d5ba7d05 Some doc fixes (#100)
* fix up Args doc block.

* add a module doc string
2019-01-25 14:51:01 -05:00
Thomas Van Lenten f5e50bc53c Add a build_test rule. (#97)
* Add a build_test rule.

This rules (marco) provides a 'test' target that can be used to ensure other
targets build.
2019-01-25 14:34:15 -05:00
c-parsons 197d869482
fix various linter errors (#93) 2019-01-14 12:41:43 -05:00
László Csomor 8d4f7612b2
maprule: an improved version of genrule() (#86)
maprule() is an improved version of
native.genrule(), with the following advantages:

- Maprule can process source files in parallel,
  creating separate actions for each of them.

- Maprule does not require declaring all output
  files. Instead you declare templates for the
  output files yielded for each source. Therefore
  N source files and M templates yield N*M
  outputs.

- Maprule supports both Bash and cmd.exe syntax
  for its commands via the specialized rules
  bash_maprule and cmd_maprule.

- Maprule's cmd attribute does deliberately not
  support $(location) expression nor Make
  Variables, in order to avoid issues and
  challenges with quoting. (In case of cmd.exe
  passing empty arguments is impossible). These
  paths can be passed as envvars instead.

- Maprule's add_env attribute does support
  $(location) expressions (and some extra
  placeholders) and is the idiomatic way to pass
  execpaths of labels in "tools" or "srcs" (the
  shared sources available for all actions) to the
  command.

See https://github.com/bazelbuild/bazel/issues/4319
2019-01-08 09:04:53 +01:00
Thomas Van Lenten 4795fd6146 Run buildifier --lint=fix over the files. (#88)
Fixes some dict order issues with the current version of buildifier.
2019-01-02 14:47:44 -08:00
László Csomor daf5137022
unittest.bzl: supports Windows (#84)
In this commit:

- change unittest.bzl to declare a named output
  file instead of relying on the deprecated [1]
  default output name (ctx.outputs.executable).

- define a new toolchain_type and toolchain rules
  for cmd.exe and for Bash (basically Windows and
  non-Windows)

- register the new toolchains in workspace.bzl

- let unittest.make-created test rules require the
  new toolchain_type

- write the test output script as a Windows batch
  script or as a Shell script, depending on the
  selected toolchain

This PR enables the Bazel team to break the Bash
dependency (for test execution) on Windows, and
can run Starlark unittests with the new,
Windows-native test wrapper (still under
development).

See https://github.com/bazelbuild/bazel/issues/5508
2018-12-04 16:14:08 +01:00
Thomas Van Lenten 8c575e737f Fix up lint issues. (#77)
Fixed via `buildifier --lint=fix` with buildifier 0.19.2.1
2018-11-26 17:31:29 -05:00
bttk db3ce78dc2 Remove supports for make(depset()) from new_sets (#68)
With `--incompatible_depset_is_not_iterable` depset is no longer
iterable. Remove tests that assumed it is.

Bazel issue:
https://github.com/bazelbuild/bazel/issues/5816
2018-11-14 18:10:38 +01:00
c-parsons 6e2d7e4a75
Rename a number of instances of 'skylark' to 'starlark' or 'bzl'
Most notably, this renames/moves a few important identifiers:

//:skylark_library.bzl -> //:bzl_library.bzl
skylark_library -> bzl_library
SkylarkLibraryInfo -> StarlarkLibraryInfo
2018-09-28 09:09:18 -04:00
Thomas Van Lenten b5f4086001 Remove usage and suggests for lib.bzl.
As more things are added, lib.bzl is an anti-pattern as the cost of loading
it actually just keeps increasing and most things will never use everything
out of it.  The pattern the should be used is to directly import the modules
one uses.
2018-08-24 15:00:13 -04:00
Thomas Van Lenten e5203c0f5d Reformat .bzl files with buildifier and add format check.
Buildifier 0.12.0 includes initial support for reformatting .bzl files.
- Reformat all the bzl files.
- Expand the travis check to check the .bzl files also.
2018-06-13 10:58:35 -04:00
Taras Tsugrii b09d5d41b2 Add type checking functions.
Even though it's not great to use type checks, they are frequently useful for
checking input types of macros.

Because there is no standard way of checking types, at least 2 types of checks
are used:
- `type(foo) == type([])`
- `type(foo) == "list"`

The first option is not very readable and the second option seem to be relying
on an Bazel implementation detail. Encapsulating type checks into this library
enables consistent and easy to understand type checking without explicitly
relying on implementation details.
2018-05-09 10:55:40 -07:00
dmaclach 4eb28c458c Add support for repr/str to new_sets (#42) 2018-05-04 15:39:54 -07:00
Thomas Van Lenten 809940bf89 Skylint: stop using ctx.outputs.executable.
Be explicit about the file create/to run instead of using
ctx.outputs.executable.
2018-05-01 14:34:36 -04:00
Thomas Van Lenten c8dae2702f
Address skylint warnings on the tests. (#39)
* Skylint: Move comment out of docstring.

Is skylint seems more than a single like docstring, it expect a full comment
with Args/Returns/etc.; avoid having to have full docstring but just making
the comment a comment and not part of the docstring.

* Address some skylint issues.

- ctx.file_action -> ctx.actions.write
- Return an empty list of providers rather then an old style empty struct.
2018-05-01 14:12:52 -04:00
Nicholas Titcombe 0b40ea7b13 Introduce new_sets.bzl (#32)
This version is hash-based (implemented on top of a dictionary) and doesn't suffer the performance problems of the current version. It will eventually replace the old one after a deprecation period.
2018-04-20 14:44:25 -07:00
dmaclach d46b607d98 Add support for 'functools.partial' like functionality. (#34)
* Add support for 'functools.partial' like functionality.

https://docs.python.org/3/library/functools.html#functools.partial
2018-04-17 09:33:38 -07:00
Thomas Van Lenten dd4cdb95c7 Don't special case current directory relative paths. 2018-03-07 14:30:43 -05:00
Jingwen 34d62c4490 Added a lib for version checking and comparison (#13) 2018-01-12 09:18:55 -08:00
Tony Allevato 82b3ad6e9e Initial check-in. 2017-10-10 07:59:31 -07:00