aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2022-02-10Add support for 'loading' unit tests, which evaluate a LOADING phase. (#347)Kevin Kress
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-10Fix linter warnings with new buildifier version. (#349)Alexandre Rostovtsev
2021-10-25Use more portable `#!/usr/bin/env bash` shebang instead of hardcoded ↵Yesudeep Mangalapilly
/bin/bash. (#329)
2021-10-04Improve escaping in unittest failure message (#320)Samuel Freilich
2021-09-23Allow specifying additional aspects to tut (#299)Daniel Wagner-Hall
2021-08-09Remove `$` from grep regexes (#311)Philipp Wollermann
Due to grep having dropped support for handling line-ending matches in a cross-platform way, grepping for `...$` will now fail on Windows, as it no longer ignores the CR part of the CRLF line endings on Windows. This should turn this project green again on Bazel CI.
2021-05-03to_json/to_proto methods on structs are deprecated and will be removed (#295)Alexandre Rostovtsev
2021-03-31lint warning fix (#115)c-parsons
2021-03-31Add shebang lines to tests directory shell scripts (#288)Olek Wojnar
2020-11-12Enable unittest.suite to accept partial calls of test rules (#276)David Sanderson
* 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-09-25Address latent buildifier issues. (#278)David Sanderson
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-08-20Improve inspect_output_dirs_test bin_dir comparison (#267)c-parsons
This should fix some buildkite CI flows, ensuring success of this test is no longer tied to the current compilation_mode. It also improves the error message of the offending evaluation.
2020-07-10copy_file: Add parameter to allow symlinks (#252)Yannic
* copy_file: Add parameter to allow symlinks This change adds a new parameter `allow_symlinks` to `copy_file` that allows the action to create a symlink instead of doing an expensive copy if the execution platform (host) allows it. Updates #248 * Update docs * Refactor `is_executable` into attribute * Fix typo * s/_impl/_copy_file_impl/
2020-06-24Remove --experimental_build_setting_api usage (#249)Julie
* Remove --experimental_build_setting_api usage Deprecating this flag so removing all usage. * One more rm * fix , * Revert semantics flags change
2020-06-19Address lint errors (#254)Andrew Z Allen
2020-04-15Add license and copyright notice (#245)Laurent Le Brun
2020-04-14Fix diff_test when filepath includes external (#241)Robbert van Ginkel
Resolves https://github.com/bazelbuild/bazel-skylib/issues/240.
2020-04-03Depend on bzl_library, not on individual bzl files (#244)Laurent Le Brun
2020-03-25Fix type parsing errors on "always true" conditions. (#239)Greg
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-02-27Create a helper rule for selecting a file from outputs of another rul… (#233)irengrig
* Create a helper rule for selecting a file from outputs of another rule or a filegroup by subpath * Add tests * Address code review comments * + formatting Co-authored-by: c-parsons <cparsons@google.com>
2020-02-06Add absolute path tests for Windows (#230)Bor Kae Hwang
2020-02-03Remove old_sets.bzl (#231)Laurent Le Brun
It has been deprecated for a while, the code is not really compatible with Bazel depset-related changes.
2019-10-29make select_tests resilient to default configuration differences (#212)c-parsons
2019-10-08Remove genfiles_dir retrieval method (#203)upstream/1.0.1c-parsons
genfiles_dir has been the same as bin_dir for several Bazel releases, and is being fully removed in upcoming Bazel release.
2019-10-08Expose target_under_test's bin and genfiles path (#202)Samuel Freilich
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-09-17Add types.is_set() to test whether an arbitrary object is a set as defined ↵TechSY730
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-17Delete maprule. Fix Buildifier lint errors. (#192)László Csomor
* Delete maprule. Fix Buildifier lint errors. Delete maprule and its tests: I wrote this rule, and I no longer plan to release it. Alternative rules exist that serve users' needs better. Fix also Buildifier lint errors that were making BuildKite red: https://buildkite.com/bazel/bazel-skylib/builds/659#ab98ac31-6e1c-415e-b8a8-5f8868340c7d
2019-06-14Create common build settings (#154)Julie
Create common simple build settings for people to use so they don't recreate these rules over and over again. This fulfills part of the SBC design doc: https://docs.google.com/document/d/1vc8v-kXjvgZOdQdnxPTaV0rrLxtP2XwnD2tAZlYJOqw/edit#bookmark=id.iiumwic0jphr
2019-06-05selects.bzl: Add config_setting_group for config_setting AND/OR-chaining (#89)Greg
* 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-04Add some comments to unittest_test.sh (#159)c-parsons
2019-05-28Make sets.bzl point to new_sets.bzl instead of old_sets.bzl (#158)c-parsons
* 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-21run_binary: runs an executable as an action (#153)László Csomor
This rule is an alternative for genrule(): it can run a binary with the desired arguments, environment, inputs, and outputs, as a single build action, without shelling out to Bash. Fixes https://github.com/bazelbuild/bazel-skylib/issues/149
2019-05-14New rules: native_binary and native_test (#152)László Csomor
native_binary() wraps a pre-built binary or script in a *_binary rule interface. Rules like genrule can tool-depend on it, and it can be executed with "bazel run". This rule can also augment the binary with runfiles. native_test() is similar, but creates a testable rule instead of a binary rule. Fixes https://github.com/bazelbuild/bazel-skylib/issues/148 RELNOTES[NEW]: The new `native_binary()` and `native_test()` rules let you wrap a pre-built binary in a binary and test rule respectively.
2019-05-09write_file: support different line endings (#150)László Csomor
The user can specify which line endings they want write_file to use. This helps avoiding line ending mismatches with diff_test. Example: diff_test verifies that a rule generates correct output by comparing it to a checked-in "golden" file. Both files are text files, and the user builds on Windows but the golden file was written on Linux and git checkout preserved original line endings. Without explicitly specifying which line endings to use, this diff_test would fail on an otherwise good output. With explicit line endings we don't need to check in the golden file to git, we can just generate it with "auto" line endings.
2019-05-08Minor formatting changes plus doc updates (#147)c-parsons
2019-05-07Fix a number of misc issues to allow google usage of bazel-skylib (#146)c-parsons
* Fix a number of misc issues to allow google usage of bazel-skylib 1. Missing copyright header 2. Shell test fixes to use TEST_TMPDIR to have write access to directories 3. diff_test fix to use TEST_SRCDIR * added a comment as to why diff_test_tests is local * ran buildifier
2019-05-06Use TEST_SRCDIR for shell tests (#145)c-parsons
Fixes https://github.com/bazelbuild/bazel-skylib/issues/143
2019-05-01Add licenses() to all BUILD files. (#141)Thomas Van Lenten
2019-04-12diff_test: add rule and tests (#136)László Csomor
This new test rule compares two files and passes if the files match. On Linux/macOS/non-Windows, the test compares files using 'diff'. On Windows, the test compares files using 'fc.exe'. This utility is available on all Windows versions I tried (Windows 2008 Server, Windows 2016 Datacenter Core). See https://github.com/bazelbuild/bazel/issues/5508 See https://github.com/bazelbuild/bazel/issues/4319
2019-04-02Reformat with buildifier --warnings=all (#138)Thomas Van Lenten
Fixes some dictionaries to put things in the more common orders. Buildifer used to default to doing this check and reformatting which is why the //conditions:default got moved up in these in the first place.
2019-03-26Windows: fix tests for native test wrapper (#129)László Csomor
All tests work with `--incompatible_windows_native_test_wrapper` except for the ones already broken on Windows (//tests:analysis_test_e2e_test and //tests:unittest_e2e_test). See https://github.com/bazelbuild/bazel/issues/6622
2019-03-20maprule: hide it, not ready for public use. (#133)upstream/0.8.0László Csomor
Move maprule() to a private directory, to discourage use of it. I (@laszlocsomor) am planning breaking changes to it. Also move private files (rule implementations) to a subdirectory "rules/private/", to clean up the "rules/" directory.
2019-03-20Accept kwargs in dicts.add() (#130)Dave Lee
Accept kwargs in dicts.add()
2019-03-20maprule: add basic integration test (#131)László Csomor
2019-03-19e2e tests: make them run on Windows (#121)László Csomor
2019-03-19write_file: add rule and tests (#122)László Csomor
This PR adds two new rules: write_file and write_xfile. Both rules solve a common problem: to write a text file with user-defined contents. The problem is routinely solved using a genrule. That however requires Bash, since genrules execute Bash commands. Requiring Bash is a problem on Windows. The new rules do not require any shell. The only difference between the rules is that write_xfile creates an executable file while write_file doesn't. See https://github.com/bazelbuild/bazel/issues/4319
2019-03-18copy_file: add rule and tests (#123)László Csomor
This PR adds two new rules: copy_file and copy_xfile. Both rules solve a common problem: to copy one file to another location. The problem is routinely solved using a genrule. That however requires Bash, since genrules execute Bash commands. Requiring Bash is a problem on Windows. The new rules do not require Bash on Windows (only on other platforms). The only difference between the rules is that copy_xfile creates an executable file while copy_file doesn't. See https://github.com/bazelbuild/bazel/issues/4319
2019-03-04maprule: use ctx.resolve_tools (#117)László Csomor
In this PR: - In the _resolve_locations function: use the Bash-less ctx.resolve_tools function to resolve the runfiles manifests and inputs of tools, instead of using ctx.resolve_command for the same purpose. - In the _custom_envmap function: no longer resolve $(location) references when creating the envvars from custom_env, because those references were already resolved in _resolve_locations. The ctx.resolve_tools() method was added in this PR: https://github.com/bazelbuild/bazel/pull/7139 See design doc there.
2019-02-22fix a number of warnings found by Starlark analyzer (#114)c-parsons
2019-02-20analysistest API for retrieval of actions registered by target under testc-parsons