rust-skeptic icon indicating copy to clipboard operation
rust-skeptic copied to clipboard

The usage with workspace

Open dalance opened this issue 6 years ago • 0 comments

I want to use rust-skeptic with workspace. My project structure is like below:

$ tree
.
|-- Cargo.lock
|-- Cargo.toml
|-- README.md
|-- crate-A
|   |-- build.rs
|   |-- Cargo.toml
|   |-- src
|   |   `-- lib.rs
`-- crate-B
    |-- Cargo.toml
    `-- src
        `-- lib.rs

I want to test README.md with crate-A, so build.rs of crate-A is below:

fn main() {
    skeptic::generate_doc_tests(&["../README.md"]);
}

This works fine with cargo test, but cargo package is failed. This is because cargo package copies files in crate-A to target/package/crate-A-xxx, build.rs is executed in the target directory, and ../README.md can't be found.

My current workaround is below:

fn main() {
    let path = std::path::PathBuf::from("../README.md");
    if path.exists() {
        skeptic::generate_doc_tests(&[path]);
    }
}

Is there any idea to fix it? I think either the improvement of rust-skeptic or the extra instruction of README.md is required.

dalance avatar Mar 12 '20 12:03 dalance