Skip to content
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

Make it easier to use rust_test_suite in macros. #791

Merged
merged 2 commits into from
Jun 24, 2021

Conversation

sayrer
Copy link
Contributor

@sayrer sayrer commented Jun 24, 2021

As written, this function produces duplicate test rules if used in macros. This patch aims to make it easy to run integration tests with different crate_features, via a macro.

@google-cla google-cla bot added the cla: yes label Jun 24, 2021
@UebelAndre
Copy link
Collaborator

As written, this function produces duplicate test rules if used in macros. This patch aims to make it easy to run integration tests with different crate_features, via a macro.

I'm not sure I understand what the prefixing gets you. Can you demonstrate how this might be used?

@UebelAndre UebelAndre self-requested a review June 24, 2021 19:08
@sayrer
Copy link
Contributor Author

sayrer commented Jun 24, 2021

def mycrate_build(name, crate_features):
    rust_library(
        name = name,
        srcs = native.glob(["src/**/*.rs"]),
        aliases = {
        },
        crate_features = crate_features,
        crate_name = name,
        ...
    )

    # Works
    rust_test(
        name = name + "_unit_tests",
        crate = ":" + name,
        crate_features = crate_features,
    )

    # Does not work due to duplicate rust_test rules
    rust_test_suite(
        name = name + "_integration_tests",
        srcs = native.glob(["tests/**/*.rs"]),
        crate_features = crate_features,
    )

@sayrer
Copy link
Contributor Author

sayrer commented Jun 24, 2021

I could see other ways to solve this, but it would be nice if the rule made it easy.

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me :) Thanks!

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the example! Looks good to me 😄

@UebelAndre UebelAndre merged commit 8cb0c78 into bazelbuild:main Jun 24, 2021
@sayrer sayrer deleted the parameterize_rust_test_suite branch June 24, 2021 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants