Commit Graph

248 Commits

Author SHA1 Message Date
Dave Lee aeefb6531a Accept kwargs in dicts.add() (#130)
Accept kwargs in dicts.add()
2019-03-20 13:08:29 -04:00
László Csomor bdbedc1832
maprule: add basic integration test (#131) 2019-03-20 07:48:42 +01:00
László Csomor b2dc5c0e63
e2e tests: make them run on Windows (#121) 2019-03-19 13:37:33 +01:00
László Csomor 2d1669ed88
write_file: add rule and tests (#122)
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-19 07:52:56 +01:00
László Csomor db27394846 copy_file: add rule and tests (#123)
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-18 13:23:15 +01:00
katre f26e8ac863 Use //... to mean "all packages" (#128)
Using just "..." makes it appear that the command output is too long and being truncated.
2019-03-17 22:29:57 +01:00
c-parsons b2b4471332
run buildifier 0.22.0 (#125) 2019-03-07 17:22:04 -05:00
Florian Weikert bb56986cd4 Fix Buildifier version (#124)
"buildifier: true" has been deprecated by https://github.com/bazelbuild/continuous-integration/pull/542
2019-03-07 16:27:24 +01:00
László Csomor 1b28145983
maprule: use ctx.resolve_tools (#117)
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-03-04 11:04:01 +01:00
c-parsons 9630853eeb
add documentation pages for rules/ and lib/ (#119) 2019-02-28 17:43:57 -05:00
Thomas Van Lenten e171ec16d8
CI updates. (#118)
- Retire the use of travis for testing.
- Update buildkite config:
  - Enable buildifier testing (close to what was on travis, and is being improved.)
  - Update the config to now test the latests release and the latest green, replacing
    the "head" testing on travis.
2019-02-27 12:21:18 -05: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
Thomas Van Lenten a565512438 CI simplification/improvements for buildifier (#113)
* buildifier 0.22.0 includes files names in diffs.

* Simplify buildifier runs even more.

Since exit status are more consistently set and output is generally better,
don't bother being as fancy and just print a simple line as lead in incase
issues are found, and use the exit status to print directions on what to
do if something comes up.
2019-02-20 20:57:59 +01: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
Dmitry Lomov aa3147f0de
Create CODEOWNERS (#103)
* Create CODEOWNERS

* Update CODEOWNERS
2019-02-14 20:24:00 +01: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 4b67f5ff38 Add rules to the test_deps target. (#102)
* Add rules to the test_deps target.

Likely needed for anyone doing integration tests using skylib.

* Default public visibility and only tag things that are private.
2019-01-28 13:51:57 -05:00
Thomas Van Lenten 97dc99e8a6 Fix example load directive. (#101) 2019-01-28 11:37:57 -05: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
Yun Peng 9b85311ab4 Enable tests on Windows (#99) 2019-01-23 16:30:16 +01:00
c-parsons 5dccaa145e
reorder toolchain targets to help clarity (#95) 2019-01-18 16:55:49 -05:00
c-parsons c41adf3888
add unittest/toolchains/BUILD as a test dep (#96)
* add unittest/toolchains/BUILD as a test dep

* remove extra whitespace
2019-01-16 17:00:03 -05:00
c-parsons 88904e62e5
add missing license notices (#94) 2019-01-14 16:00:11 -05:00
c-parsons 197d869482
fix various linter errors (#93) 2019-01-14 12:41:43 -05:00
Josh Morton 9948d5538b Wrap invocation of dict.items() in list(). (#91)
Some infrastructure parses bzl files as python, which fails when
dict.items() returns a special dict_items generator instead of a list in
python3.
2019-01-10 15:26:52 -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 6dd0b9cbd6 Buildifier fixes (#87)
* fix typo
* Handing buildifier exit status better.

buildifier started reporting an error for lint issue, update the script
to not stop because of that.
2019-01-02 14:48:03 -08: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
Kelly Campbell c00ef49386 Fix load paths examples in README (#80) 2018-12-06 11:31:32 -05: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
Nathan Herring f4a2bae427 Fix Skylark analyzer warning. (#81) 2018-11-29 11:53:05 +01:00
Thomas Van Lenten d9cd300c64
Add WORKSPACE to the things checked by buildifier. (#79)
Move the find args into a shell variable to simplify things.
2018-11-27 07:55:22 -05:00
Nathan Herring 5b8a8d3e31 Fix skylark_library deps for new_sets and unittest. (#76)
* Add dicts to new_set's dependencies.

Fixes issue 75.

* Add new_sets to deps for unittest.
2018-11-27 11:50:34 +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
Thomas Van Lenten d7c5518fa0
buildifier lint issues/validation
* Fix lint issues

- Move the doc string into the `doc` attributes on the rule/attr calls.
- Move the print() below the load() statements.

* Also run buildifier in --lint=fix mode to catch issues on Travis.
2018-11-21 13:04:25 -05:00
bttk 9566d63ba0 Rename sets.bzl to old_sets.bzl (#70)
* Rename sets.bzl as old_setz.bzl

* Reexport old_sets.bzl in sets.bzl

* Add old_sets.bzl to :sets
2018-11-20 16:54:09 -05:00
c-parsons 9992d61921
add cparsons and bttk to the CONTRIBUTORS file (#73) 2018-11-20 15:19:06 -05:00
c-parsons 58f9c41304
make sets.bzl compatible with --incompatible_depset_is_not_iterable (#71) 2018-11-20 13:19:38 -05:00
bttk 3b30154839 Use transitive_files in runfiles instead of a list of files (#69) 2018-11-14 18:52:55 +01:00
Thomas Van Lenten b12cc99ee3
Use Xcode 10.1 on the travis CI setup. (#66) 2018-11-14 12:33:18 -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
bttk 3360231ec0 Upgrade to the new actions API (#65)
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
2018-11-13 11:22:18 +01:00
Thomas Van Lenten 6ad5e286cb Cache the types to avoid fetching it every time. (#64)
Along the lines of the caching done in #62
2018-11-13 00:03:11 +01:00
TechSY730 7a9648fed6 Update to google style (#63)
* Update skylark_library.bzl to conform to Google's code style.
2018-11-12 12:42:57 -08:00
TechSY730 d17ca08d28 Make _precondition_only_sets_or_lists in sets.bzl not assume type() returns a string. (#62)
Such an assumption makes this check brittle in the face of potential future changes to type().
2018-11-12 19:44:29 +01:00
Julio Merino 8cecf885c8 Remove spurious newlines from fail/print messages (#60)
The fail() and print() primitives take strings without newlines in them
because the formatted output will already contain newlines.  Therefore,
remove them, which have been annoying me to no end when using rules_go
with a HEAD-built Bazel binary.

While doing this, also switch to using .format() consistently for all
strings, merge two related debug messages into the same print() call,
and fix grammar.
2018-10-18 16:04:01 -07:00