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

Allow creating test binaries with predictable names #12004

Closed
jjant opened this issue Apr 20, 2023 · 3 comments
Closed

Allow creating test binaries with predictable names #12004

jjant opened this issue Apr 20, 2023 · 3 comments
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@jjant
Copy link

jjant commented Apr 20, 2023

Problem

I have a fleet of machines that build code, on these I want to run cargo build --tests to build a test binary, and hand that over to the machines that actually run the tests.

At the moment, because the generated binary has a non-predictable name (it contains a hash), we'd have to resort to the annoying trick of using --mesage-format=json and parse the output json to find the binary. See example.

Proposed Solution

It'd be nice to have a flag to name the test executable: cargo build --tests --out-name="my-tests-binary", or a way to remove the hash from the name.

Notes

No response

@jjant jjant added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Apr 20, 2023
@weihanglo
Copy link
Member

Thanks for the report!

It feels like Cargo targets generally have the same problem; only some of them are uplift to target/{debug,release}/ directory and have hash suffix erased. From my understanding, test/bench/example targets weren't designed to share final artifact outside the project.

There is an unstable feature different-binary-name (tracking issue #9778) enabling Cargo to set a different file name for [[bin]] targets. There are some discussions around mkaing it support [lib] target as well. Not sure if we want to extend its functionality to tests/benches/examples.

OTOH, here is a cargo rustc workaround. Could you try if it meets your need?

cargo rustc --test myinteg-test -- --emit link="myinteg-test.exe"

@weihanglo weihanglo added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) and removed S-triage Status: This issue is waiting on initial triage. labels Apr 20, 2023
@ehuss
Copy link
Contributor

ehuss commented Apr 20, 2023

I believe this is a duplicate of #3670.

@weihanglo
Copy link
Member

Thanks for the info. Closing in favor of #3670.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
None yet
Development

No branches or pull requests

3 participants