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

Dummy main.rs files can result in confusing binaries which do nothing #212

Open
teor2345 opened this issue Apr 24, 2023 · 1 comment
Open

Comments

@teor2345
Copy link

teor2345 commented Apr 24, 2023

We're using cargo chef to build a test Docker image.

In our acceptance tests, we were not building some of the required test binaries from another crate. (This is an unstable cargo feature -Z bindeps, which you can workaround using an empty integration test.)

So the binary we were copying was built by cargo chef cook in an earlier stage, with an empty main.rs. We spent some time trying to work out why it wasn't producing any output in our tests.

Here is how we were originally using cargo chef:
https://github.com/ZcashFoundation/zebra/blob/7681da374dde00022a0efadce811e3a7a18a3fb4/docker/Dockerfile#L110

And here's the changes we needed to get the new test working:

Incomplete change - just copy the (fake) binary:
https://github.com/ZcashFoundation/zebra/pull/6550/files#diff-f34da55ca08f1a30591d8b0b3e885bcc678537b2a9a4aadea4f190806b374ddcR117

Workaround - build the binary for the tests:
https://github.com/ZcashFoundation/zebra/pull/6550/files#diff-e7a58077f5761507dda333fd31c1f456f16a05d7a090175883709edf64ecce2cR1-R9

This seems like something worth documenting.
Can you also make the fake binaries log a message explaining why they don't do anything?

Edit:
Or can you delete them after that stage has been built?

@teor2345
Copy link
Author

Thinking about this a bit more, logging a message could cause issues for no-std projects. So is it possible to delete the empty binaries after that stage has been built?

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

No branches or pull requests

1 participant