I have found a number of times that there are crates on crates.io which do not have working tests, this can cause example code in documentation to fail for users of libraries. I think that it would be useful if cargo test was performed automatically before the crate is able to be published, that way encourages crate owners to ensure that the crate is in a good state.
Do people have any views on why this would be a bad thing?
I think that those fall into a different category and may be more like things for cargo-release, whereas I think that the tests are things which relate to the quality of crates and thus should be used by all (hence including in the cargo publish command).
I was thinking to have it more as a gentle reminder to ensure that prior to publishing the crate tests ok (maybe with a flag to allow overriding like allow-dirty), rather than a server side rejection of the crate.
Also even if the tests are not distributed, surely it would at least make sense to ensure that the doc tests are valid to ensure that people using the libraries are not trying to use the library wrong.
In general, I like the idea of running tests before publishing.
On one hand I see this as a reasonably easy way to get new maintainers to realize that they broke a test before publishing a new version. On the other hand, most maintainers are already executing tests before publishing a new crate version.
I agree that most do run tests (hence this should not cause much disruption to crate owners), however this would ensure that they have and help improve the quality of crates. This is especially true of doc tests, where if a crate is published the doc tests are part of how to use the interface and thus I would argue should always pass.
The onus is on the crate authors to have a well formulated CI process that makes his step redundant. Testing is a wide term especially in rust where you could have a variety of rust versions, platforms, combinations feature gates enabled/disabled which could make it difficult for cargo publish to generalise it for all