I find it more ergonomic to add notes or a description about a test to a `doc` attribute, similar to other rules, vs a comment block above it or in the `impl` function docstring. Hopefully this can improve the readability of test rules.
This is a relatively simple addition to unittest that statically creates rules
that either explicitly fail or not depending on if the test case is valid during
LOADING phase of bazel. The test conditions are evaluated entirely in loading
phase, but if we want an actual test to fail rather than just `fail()` killing
the build, we can use this to assert state and report test failures.
* Enable unittest.suite to accept partial calls of rules
This permits using `unittest.suite` with test rules that have nondefault
attributes, while retaining compatibility with current usage.
For instance, this permits setting a `timeout` on each test in a
`unittest.suite`. Previously, all tests in a `unittest.suite` would
have the default timeout, with no good way to alter this. This
made it hard to eliminate all the warnings produced from using the
`--test_verbose_timeout_warnings` bazel option.
While timeouts were the motivation, the solution here is not specific
to timeouts. It will permit arbitrary additional arguments to the test
rules in a `unittest.suite`.
Fixes #98
* Respond to review feedback.
* Document a breaking change in bazel that this code needs to be aware of.
The output directories for the target under test may differ when the target is under a config transition (config_settings is passed to analysistest.make). Since analysis tests may assert about the command-line of generated actions, and those command-lines may contain paths to output files, this is useful information to expose.
* Make sets.bzl point to new_sets.bzl instead of old_sets.bzl
new_sets.bzl and old_sets.bzl should be removed in the following skylib release.
Fixes #155.
* update and rename test suites
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
In future Bazel releases ctx.file_action will be removed.
ctx.action.write should be used instead.
With this change tests pass even if --incompatible_new_actions_api
is used.
Bazel issue:
https://github.com/bazelbuild/bazel/issues/5825
Most notably, this renames/moves a few important identifiers:
//:skylark_library.bzl -> //:bzl_library.bzl
skylark_library -> bzl_library
SkylarkLibraryInfo -> StarlarkLibraryInfo
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.
* Fix up the skylint warning about depset usage.
* Remove the reassignment of max_bazel_version.
This was flagged by skylint, the reality is _is_at_most() does the parsing
so it shouldn't be parsed before sent on the way.
* Fix up the skylint warning about depset usage.
* Fixup the skylint warning about re-exports.
Just move to the explicit re-export form.
* Fix the fail() call to use the right variable.
skylint flagged this variable as undefined, but it it seems like this
was never right and should have been "key" all along.
* Fixup docstring formatting for skylint.
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.