Make `cargo contract test` run the contract's doc tests as well
Created by: cmichi
Follow-up to https://github.com/paritytech/ink/pull/1198.
Issue Description
If one executes cargo test
for an ink! contract, the doc tests are not run. This is because our contract crates are of type cdylib
(relevant Rust issues: https://github.com/rust-lang/cargo/issues/4717, https://github.com/rust-lang/cargo/issues/2442).
Proposal
Have cargo contract test
run in a temporary workspace (like here with a subsequent call of using_temp
), remove crate-type = ["cdylib"]
from the temporary contract's Cargo.toml
, run the doc tests.
You can use this method for removing the crate-type
.
ToDo
-
Make cargo contract test
run the contract's doc tests as well. -
Add a flag --doc
analog tocargo test --doc
. -
Make all our CI's which test contracts use cargo +nightly contract test
instead of executingcargo test
on the contract. -
Ensure that the workshop + ink-docs
always usecargo +nightly contract test
overcargo test
.