Helpers for making test assertions

Macros and Functions

assert_contains

Generates a test target which fails if the file doesn't contain the string.

Depends on bash, as it creates an sh_test target.

Example usage (generated)

load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")

assert_contains(
    # target to create
    name = "",
    # Label of a file
    actual = None,
    # a string which should appear in the file
    expected = None,
)

name

target to create

actual

Label of a file

expected

a string which should appear in the file

size

the size attribute of the test target

timeout

the timeout attribute of the test target


assert_outputs

Assert that the default outputs of a target are the expected ones.

Example usage (generated)

load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs")

assert_outputs(
    # name of the resulting diff_test
    name = "",
    # string of the label to check the outputs
    actual = None,
    # a list of rootpaths of expected outputs, as they would appear in a runfiles manifest
    expected = None,
)

name

name of the resulting diff_test

actual

string of the label to check the outputs

expected

a list of rootpaths of expected outputs, as they would appear in a runfiles manifest