google / google/jsonnet

Standalone Jsonnet integration test suite

Open
#141 10 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

Now that a pure-Go implementation of Jsonnet is being developed (google/go-jsonnet) is being developed, it would be a good idea to make it possible to share the Jsonnet's rich test suite across different implementations.

Perhaps we can move the test suite into a separate repo and set it up so that it can be used to test any Jsonnet implementation that exposes the same command line interface. It should be possible to set this up using Bazel. We already have a [`jsonnet_to_json_test`](https://github.com/bazelbuild/rules_jsonnet#jsonnet_to_json_test) rule that can be used to run all of the integration tests aside from the formatter tests, for which it would be easy to write a test rule for. We can then use Bazel's external repository mechanism to include this test suite and add the test targets.

Here is how I imagine this will work:

Say that we move the test suite to the repository google/jsonnet-test-suite. We can add a [Skylark macro](http://bazel.io/docs/skylark/macros.html) called `jsonnet_test_suite` that would take a label for a Jsonnet command line binary as an argument. When this macro is used, it will add a bunch of `jsonnet_to_json_test` test targets that would be run with the given Jsonnet binary.

Then, in `google/jsonnet` and `google/go-jsonnet`, we can include the `google/jsonnet-test-suite` repository by adding the following to the WORKSPACE file:

``` python
git_repository(
name = "jsonnet_test_suite",
remote = "https://github.com/google/jsonnet-test-suite",
tag = "v0.0.1",
)
```

Say that `//cmd:jsonnet` is the build label for the `jsonnet` binary. Then, we can add a BUILD file under the `test_suites` directory with the following:

``` python
load("@jsonnet_test_suite//:test_suite.bzl", "jsonnet_test_suite")

jsonnet_test_suite(
name = "test_suite",
jsonnet = "//cmd:jsonnet",
)
```

Then, the entire test suite can be run against the given jsonnet binary with `bazel test //test_suite:all`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.