Skip to content

coverage binary override #3490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TroyKomodo
Copy link

Allow for the binary that the //util/collect_coverage to be overridden.

The usecase for this is because i have written a custom extension rule

nextest_test = rule(
    doc = """A test rule that runs tests using a custom test runner.

    Args:
        binary: The test binary to run
        crate_name: The name of the crate this test is for
        env: Additional environment variables
        data: Runtime dependencies for the test
        workspace_root: Optional workspace root setting
    """,
    implementation = _nextest_test_impl,
    parent = rust_test,
    attrs = {
        "workspace_root": attr.label(mandatory = False),
        "_profile": attr.label(mandatory = False, default = "//:test_profile"),
        "_test_runner": attr.label(
            default = "//dev-tools/test-runner",
            executable = True,
            cfg = "exec"
        ),
        "_nextest_config": attr.label(
            default = "//:.config/nextest.toml",
            allow_single_file = True
        ),
        "_windows_constraint": attr.label(
            default = "@platforms//os:windows"
        ),
    },
)

That extends the rust_test rule and then adds a wrapper script to invoke the test via a custom runner. Due to that the TEST_BINARY env variable points to the wrapper and not the rust_test binary.

Allow for the binary that the `//util/collect_coverage` to be
overridden.

The usecase for this is because i have written a custom extension rule

```
nextest_test = rule(
    doc = """A test rule that runs tests using a custom test runner.

    Args:
        binary: The test binary to run
        crate_name: The name of the crate this test is for
        env: Additional environment variables
        data: Runtime dependencies for the test
        workspace_root: Optional workspace root setting
    """,
    implementation = _nextest_test_impl,
    parent = rust_test,
    attrs = {
        "workspace_root": attr.label(mandatory = False),
        "_profile": attr.label(mandatory = False, default = "//:test_profile"),
        "_test_runner": attr.label(
            default = "//dev-tools/test-runner",
            executable = True,
            cfg = "exec"
        ),
        "_nextest_config": attr.label(
            default = "//:.config/nextest.toml",
            allow_single_file = True
        ),
        "_windows_constraint": attr.label(
            default = "@platforms//os:windows"
        ),
    },
)
```

That extends the `rust_test` rule and then adds a wrapper script to
invoke the test via a custom runner. Due to that the `TEST_BINARY` env
variable points to the wrapper and not the `rust_test` binary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant