Benchmarks, examples and integration tests are not needed to build the package, and excluding these reduces the size of the package. However, cargo package
or cargo publish
prints warnings when excluding these. Are there any disadvantages to excluding autoXXX, etc. from the package if it is not needed?
The main disadvantage probably is that crater will no longer be able to run the integration tests of your package.
Linux distros (re)packaging crates.io crates would like to run tests, but don't want the hassle of getting them from the crate's git repo.
Despite that, I still prefer to exclude the tests:
-
there's no workflow for testing the crate after packaging, so it's possible to ship broken tests without being aware of it.
cargo publish
checks if the package builds, but it can't check if it passes the tests. Tests could be accidentally broken when run from the package, e.g. if they require data files that are weren't included, or depend on workspace's configuration. -
they're useless for users of crates.io and
cargo
.cargo
doesn't use them, and doesn't have any officially supported way of using them. -
When tests need additional data files, it can bloat the tarball. This creates overhead for all the regular users, and wastes crates-io's bandwidth. The
image
crate once accidentally included a few test images, and wasted 10TB of bandwidth per month, becoming one of the top bandwidth consumers on crates.io.
I think you can do that by getting the code from the repository. The VCS hash associated with that version can be obtained from .cargo_vcs_info.json
file. If the code is not managed in VCS or the repository is private, I think it's better to include autoXXX as well.