Commit Graph

6 Commits

Author SHA1 Message Date
TechSY730 3154dbbc41 Add types.is_set() to test whether an arbitrary object is a set as defined by new_sets.bzl. (#181)
* Add sets.is_set() to test whether an arbitrary object is a set.

Since using sets requires special API, it can be useful to determine
whether an object is a set so special handling can be used.
For example, if a method wants to be able to take a list or a set.
2019-09-17 10:21:44 -04:00
Tony Allevato 6741f73322 Add `types.is_depset`. (#105) 2019-02-08 18:37:26 +01: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 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