Commit Graph

87 Commits

Author SHA1 Message Date
Christopher Parsons 3a7511ceb0 fix a number of warnings found by Starlark analyzer 2019-02-22 16:15:13 -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
c-parsons 6e2d7e4a75
Rename a number of instances of 'skylark' to 'starlark' or 'bzl'
Most notably, this renames/moves a few important identifiers:

//:skylark_library.bzl -> //:bzl_library.bzl
skylark_library -> bzl_library
SkylarkLibraryInfo -> StarlarkLibraryInfo
2018-09-28 09:09:18 -04:00
Thomas Van Lenten 1099dd2d0a deprecate lib.bzl. (#58)
- tag the :lib target as such.
- print() a warning when lib.bzl is loaded.
2018-09-24 21:48:24 +02:00
Thomas Van Lenten e9fc4750d4 Move to Xcode 9.4 for testing. 2018-08-28 10:04:50 -04:00
Laurent Le Brun 0914f49694
Merge pull request #56 from thomasvl/avoid_lib
Remove usage and suggests for lib.bzl.
2018-08-27 16:19:16 +02: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 ca5f717eba Update the module list. 2018-08-24 14:45:54 -04:00
Thomas Van Lenten c0b0c4400e Fix executable bit on selects.bzl 2018-08-24 14:45:54 -04:00
Thomas Van Lenten 7490380c6b No need to list visibility that matches the default. 2018-07-27 12:53:08 -04:00
oquenchil 6301f974f0
Makes package public by default
When creating a skylark_library A anywhere downstream, if a bzl file in A loads() any of the bzl libraries in this package, then the bzl files in this package will have to be in deps as a skylark_library. The current public filegroup cannot be used as a dependency of skylark_libraries.
2018-06-27 10:22:33 +02:00
Thomas Van Lenten 3fea8cb680 Add missing dep 2018-06-13 14:17:14 -04:00
Thomas Van Lenten 3b6bba355c Fix up skylint issues. 2018-06-13 11:59:47 -04:00