Skip to main content
Gazelle has a fantastically easy test fixture, using “golden” files. These can be used for extensions written either in Go or in Starlark (which is great since you can use the tests to verify a port from Go to Starlark) Each test fixture is just a folder containing:
  • WORKSPACE (just as a marker file)
  • BUILD.in - what the actual BUILD file looks like before running Gazelle
  • BUILD.out - what the expected BUILD file looks like after running Gazelle
  • Other files that exist in the package and Gazelle may read
To turn a fixture into a test, use a gazelle_generation_test rule. Here’s a convenient wrapper that we use in Aspect CLI to handle dotfiles.

Example

Here’s a simple example with JSON files that participate in a dependency graph. Imagine our repository uses these to configure a code generator, and we want BUILD files to execute that generator using a custom rule called x_lib: see the full test fixture.