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 building helper binaries for tests #4356

Open
luser opened this issue Aug 2, 2017 · 4 comments
Open

Allow building helper binaries for tests #4356

luser opened this issue Aug 2, 2017 · 4 comments
Labels
A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) C-enhancement Category: enhancement Command-test S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.

Comments

@luser
Copy link
Contributor

luser commented Aug 2, 2017

I've written a few crates that do process manipulation, and when writing tests I find myself needing a helper binary to run and manipulate. Three quick examples are read-process-memory, spawn-ptrace, and spawn-task-port.

I currently just put those helper binaries in src/bin so they get built as programs, but they're not intended for end-user consumption and don't need to be built except for test usage. It would be nicer if cargo had a way to build helper binaries for tests, like perhaps .rs files under tests/bin could be treated as such? Helper binaries should be considered a dependency of running tests, so they should be rebuilt as necessary before tests are run, but could be built in parallel with the tests themselves.

@alexcrichton
Copy link
Member

Yeah I've also done this many times before too! Agreed it'd be nice to have a dedicated set of targets for this for sure.

@dwijnand
Copy link
Member

In case the backlink isn't clear, there was an initial implementation proposed in #4846, but the reality is that fixing this is going to require an RFC.

@rbtcollins
Copy link
Contributor

rbtcollins commented Feb 20, 2020

I would very much like this too - I ran into this writing an implementation abstracting across ulimits, which really needs new processes spawned on windows, where fork() isn't a thing. I'm probably willing to do an RFC, but haven't done that in this community before - can I get a pointer to the process, starting points etc.

@epage
Copy link
Contributor

epage commented Oct 17, 2023

To summarize #4846, that added tests/bin as a while new target kind.

One solution is #2911: have the test binary behind a feature and running tests automatically activates it. A hacky workaround, for now, is to have a dev-dependency on yourself that activates the feature.

Another option, if the binaries are from another package, is artifact dependencies.

@epage epage added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. C-enhancement Category: enhancement A-cargo-targets Area: selection and definition of targets (lib, bins, examples, tests, benches) labels Oct 17, 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-enhancement Category: enhancement Command-test S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted.
Projects
Status: No status
Development

No branches or pull requests

5 participants