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

run unit-test in build scripts #9942

Open
rtbo opened this issue Sep 24, 2021 · 2 comments
Open

run unit-test in build scripts #9942

rtbo opened this issue Sep 24, 2021 · 2 comments
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-test S-triage Status: This issue is waiting on initial triage.

Comments

@rtbo
Copy link

rtbo commented Sep 24, 2021

Describe the problem you are trying to solve
I have quite complex build scripts that require some unit-testing.

Describe the solution you'd like
I'd like cargo test to also run #[test] defined in build script files.

@rtbo rtbo added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Sep 24, 2021
@ehuss ehuss added the A-build-scripts Area: build.rs scripts label Oct 22, 2021
@epage
Copy link
Contributor

epage commented Sep 20, 2023

A workaround is to pull the build script logic out into a library that the build script then calls. This would be made better with rust-lang/rfcs#3452.

The challenge to this is we'd need to elevate build scripts to being a dedicated target while right now it is just a field in the package.

@weihanglo
Copy link
Member

Or make the custom build logic into a workspace member, and use it as a “build dependency”. The downside is now you need to publish your build script to crates.io.

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-test S-triage Status: This issue is waiting on initial triage.
Projects
Status: No status
Development

No branches or pull requests

4 participants