rust-lang / rust-lang/cargo

Running doc tests are slow due to being always being recompiled

Open
#2,944 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-caching A-doctests C-enhancement Command-test Performance S-blocked-external
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Originally spawned by an issue to rust-skeptic which has the same problem.

Testing my combine library which has 44 doc tests and 36 normal tests takes ~26 seconds with ~22 of those being spent in doc tests. From what I can tell this is because cargo recompiles these tests every time cargo test is run in addition to each test being compiled individually.

I am thinking this is for a good reason since it makes sure two doc tests cannot conflict with each other but it would be nice if it could be improved.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported timing with cargo test on a project containing many doc tests, and compare doc-test compilation with normal tests. Read the doc-test and test-running paths in Cargo, using the linked rust-skeptic issue for context. Done means avoiding unnecessary recompilation while preserving isolation between doc tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.