Commit Graph

86 Commits

Author SHA1 Message Date
Alexandre Rostovtsev 43c6185e7e
Make only root test_deps externally visible (#508)
All other test_deps targets implicitly require the root BUILD file
for the `license` target for their default_applicable_licenses;
therefore, users should only depend on the root test_deps target.
2024-07-15 17:57:10 +00:00
Kilian Funk 32bbb52730
fix: subpackages.all works for root packages (#530) (#531) 2024-07-12 23:36:14 +02:00
Ivo List 0e485c80b7
Add is_normalized and starts_with to paths module (#514)
* Add is_normalized and starts_with to paths module.

* Update docs
2024-05-29 15:40:38 +02:00
Alexandre Rostovtsev 0d43695bd5
Re-add `licenses()` - internal license checker still requires it :/ (#506)
And take the opportunity to fix default_applicable_licenses in the gazelle plugin
2024-05-02 14:38:05 -04:00
Alexandre Rostovtsev a16ebb4dca
Add `default_applicable_license` and remove obsolete `licenses()` in all BUILD files (#504) 2024-05-01 17:24:18 -04:00
Philipp Stephani 700c9ec92b
Improve compatibility with Bazel 6. (#499)
In Bazel 6, the doc parameter of the module_extension function doesn’t accept
None; cf. https://bazel.build/versions/6.5.0/rules/lib/globals#module_extension
vs. https://bazel.build/versions/7.0.0/rules/lib/globals/bzl#module_extension.
Instead of passing None in that case, just don’t pass the argument at all and
use the respective default.
2024-04-25 15:45:04 +02:00
Fabian Meumertzheim 1969278310
Mark `modules.as_extension` as `reproducible` (#497)
WORKSPACE macros are fully deterministic and thus a prime example of a `reproducible` module extension. This reduces clutter in `MODULE.bazel.lock`.
2024-04-24 23:26:33 +02:00
Fabian Meumertzheim 553c08dc60
Add helper functions for module extensions as `modules` (#456)
Adds a new module `modules` with two helper functions for module
extensions:

* `use_all_repos` makes it easy to return an appropriate
  `extension_metadata` from a module extension (if supported) to
  indicate that all repositories generated by the extension should be
  imported via `use_repo`.
* `as_extension` turns a WORKSPACE macro into a module extension that
  uses `use_all_repos` to automate the generation of `use_repo` calls.
2024-04-24 14:53:32 -04:00
JY Lin 60241d2e06
Add toolchains argument to unittests.make (#483)
* Add toolchains argument to unittests.make

Make unittests.make bypass toolchains arguments to target rule's constructor.

* update doc

---------

Co-authored-by: JiaYan Lin <jiayanl@google.com>
2024-01-08 09:37:19 +01:00
UebelAndre d77c6fbaf7
Add `doc` param to `unittest.make` (#464) 2023-10-31 08:52:17 +01:00
Fabian Meumertzheim 652c8f0b28
versions: Don't fail on Bazel dev builds (#463)
Dev builds of Bazel are assumed to be more recent than any released
version.
2023-09-25 18:25:37 -07:00
Vinh Tran 1bbb388780
Update unittest_doc.md with analysistest and loadingtest modules (#370)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-26 09:21:43 -04:00
Vinh Tran 69b4636956
Fix doc error for analystest.begin (#369)
Co-authored-by: Alexandre Rostovtsev <arostovtsev@google.com>
2022-08-25 17:47:50 -04:00
Kevin Kress cc51024fc2
Add subpackages module to skylib to support new bazel native.subpackages (#348) 2022-04-04 17:56:21 -04:00
Barry McNamara 8334f938c1
Implement omit and pick dicts functions. (#304) 2022-03-17 16:49:06 -04:00
UebelAndre cdd0afdfe6
Fixed positional args for unittest targets (#352)
Followup to https://github.com/bazelbuild/bazel-skylib/pull/343
2022-02-10 17:55:11 -05:00
UebelAndre 2bc90bdf7d
Allow unit test rules to be documented (#343)
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.
2022-02-10 17:00:29 -05:00
Kevin Kress 7270e3b345
Add support for 'loading' unit tests, which evaluate a LOADING phase. (#347)
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.
2022-02-10 16:03:48 -05:00
Samuel Freilich 506c17293e
Improve escaping in unittest failure message (#320) 2021-10-04 12:03:48 -04:00
Daniel Wagner-Hall 08398cdc99
Allow specifying additional aspects to tut (#299) 2021-09-23 16:21:58 -04:00
dmaclach b053a5ae11
Update partial.bzl to generate better markdown (#309) 2021-07-26 15:26:28 -04:00
Alexandre Rostovtsev 7b859037a6
to_json/to_proto methods on structs are deprecated and will be removed (#295) 2021-05-03 12:27:40 -04:00
David Sanderson ed7f03cde6
Enable unittest.suite to accept partial calls of test rules (#276)
* 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.
2020-11-12 21:04:39 -05:00
David Sanderson 56ec790c9b
Address latent buildifier issues. (#278)
In https://buildkite.com/bazel/bazel-skylib/builds/1240#annotation-buildifier
I noticed buildifier issues unrelated to my PR.
This PR attempts to address these latent buildifier issues.
2020-09-25 22:32:06 +02:00
Ivo List dc080e9516
Prettify failure message of asserts.set_equals. (#263)
Before, when comparing large sets, the message dumped the whole set. Now it additionally prints missing and unexpected elements.
2020-08-11 14:52:32 +02:00
Bocete 2a44ef8ec8
Add `new_sets` as a dep of `sets` bzl_library (#253)
Without this change, evaluating bzl with strict dependencies results in an error.

[`load(":new_sets.bzl", _sets = "sets")`](560d7b2359/lib/sets.bzl (L17)) results in `No such file or directory: 'third_party/bazel_skylib/lib/new_sets.bzl`
2020-07-22 08:51:32 +08:00
Andrew Z Allen d35e8d7bc6
Create Gazelle language for Starlark (#251) 2020-06-26 17:04:12 +02:00
Andrew Z Allen 3b666f525d
Address lint errors (#254) 2020-06-19 19:49:52 +02:00
Laurent Le Brun 2d0c651291 Update visibility of files (#243)
Stardoc needs access to a file (with exports_files) in order to
generate its documentation.
2020-04-02 22:20:57 +02:00
Greg dfcfe82500
Fix type parsing errors on "always true" conditions. (#239)
Specifically:

selects.config_setting_group(
    name = "always_true",
    match_any = ["//conditions:default"],
)

and

selects.config_setting_group(
    name = "always_true",
    match_all = ["//conditions:default"],
)

These should, as expected, always evaluate to True.
Their implementation had a bug that failed the build outright.
2020-03-25 14:05:24 -04:00
Thomas Van Lenten 2d620ba1f8
Fix the comment to match the code. (#238)
Looking at the impl, it only accepts sets.
2020-03-19 12:40:56 -04:00
Thomas Van Lenten add8e42934
Run buildifier over the directory. (#235)
Using the 1.0 release.

```
buildifier -r .
```
2020-02-18 13:17:37 -05:00
Laurent Le Brun e583e822a0
Remove old_sets.bzl (#231)
It has been deprecated for a while, the code is not really compatible with Bazel depset-related changes.
2020-02-03 16:39:21 +01:00
c-parsons cff8af42e9
Remove genfiles_dir retrieval method (#203)
genfiles_dir has been the same as bin_dir for several Bazel releases, and is
being fully removed in upcoming Bazel release.
2019-10-08 15:46:35 -04:00
Samuel Freilich 376680d276 Expose target_under_test's bin and genfiles path (#202)
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.
2019-10-08 12:39:11 -04:00
Samuel Freilich f1475299af Avoid some repetition in _make_analysis_test (#197) 2019-10-04 11:19:43 -04:00
Gabe Giosia 720f59405d Pass `fragments` through to analysis tests rule constructors. (#190)
Passing fragments through to the rule allows rules to access language specific features.
2019-10-02 14:14:17 -04:00
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
aiuto ab87410a8b
Use rules_pkg to make the skylib tarball for a release. (#185)
* add empty CHANGELOG.md to try to reuse bazel release.sh

* checkpoint a new distribution method

* Update CHANGELOG.

* checkpoint relnew

* get the tarball working

* fix visibilyt

* whitespace

* punctuation typos

* buildify

* linty fresh
2019-08-23 14:37:16 -04:00
Thomas Van Lenten d2cf1cc2bc
`print`->`fail` and suppress the warning in another case. (#177) 2019-07-22 13:25:00 -04:00
kwasimensah a6c72f2b39 Make config_setting_group visibility aware (#168) 2019-07-16 11:45:12 -04:00
aiuto c102f5d414 Get docs working again. (#165)
- Update to newer version of stardoc.
- Make lib/selects.bzl stardoc compatible. There must be a block description before Args:

Docs now generate with
    bazel build --incompatible_remap_main_repo docs:*

See https://github.com/bazelbuild/bazel/issues/7130 for reasons.
2019-07-02 12:35:55 -04:00
Greg 6a6a509f36 selects.bzl: Add config_setting_group for config_setting AND/OR-chaining (#89)
* Add config_setting_group for config_setting AND/OR-chaining

Implements https://github.com/bazelbuild/proposals/blob/master/designs/2018-11-09-config-setting-chaining.md.

* buildifier lint fixes

* Add tests

* Add test stub for both match_any and match_all

* Simplify the implementation and make it more correct. :)

* Fix styling issues
2019-06-05 17:39:51 -04:00
c-parsons 202db59ecc
Make sets.bzl point to new_sets.bzl instead of old_sets.bzl (#158)
* 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
2019-05-28 17:54:22 -04:00
Sergio Campamá ffad33e9bf Pass through an attribute arguments to `analysistest.make`. (#140)
This allows `analysistest.make` rules to be parameterized.
2019-05-03 16:24:20 -04:00
Thomas Van Lenten f80abf6578 Fix typo (#142) 2019-05-01 13:38:59 -04:00
Dave Lee aeefb6531a Accept kwargs in dicts.add() (#130)
Accept kwargs in dicts.add()
2019-03-20 13:08:29 -04:00
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 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