Skip to content

[rustdoc] Integration test documentation build failure #13427

Open
@bwidawsk

Description

@bwidawsk

Problem

When trying to build documentation for integration tests, the primary crate is not included and therefore cannot be found. This is useful for documenting common APIs in integration tests as documented

> cargo rustdoc --lib --test doctest
 Documenting rustdoc-test-repro v0.1.0 (/home/bwidawsk/dev/rustdoc-test-repro)
error[E0432]: unresolved import `rustdoc_test_repro`
 --> tests/main.rs:2:5
  |
2 | use rustdoc_test_repro;
  |     ^^^^^^^^^^^^^^^^^^ no external crate `rustdoc_test_repro`

For more information about this error, try `rustc --explain E0432`.
error: could not document `rustdoc-test-repro`

Caused by:
  process didn't exit successfully: `/home/bwidawsk/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustdoc --edition=2021 --crate-type bin --crate-name doctest tests/main.rs -o /home/bwidawsk/dev/rustdoc-test-repro/target/doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=167 -C metadata=82b36fa1636c8440 -L dependency=/home/bwidawsk/dev/rustdoc-test-repro/target/debug/deps --crate-version 0.1.0` (exit status: 1)

Steps

  1. Add documentation to an integration test
  2. build documentation something like: cargo rustdoc --lib --test doctest

A simple reproducer is here. Simple run failure.sh

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.75.0 (1d8b05cdd 2023-11-20)
release: 1.75.0
commit-hash: 1d8b05cdd1287c64467306cf3ca2c8ac60c11eb0
commit-date: 2023-11-20
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u  30 May 2023
os: Arch Linux Rolling Release [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-targetsArea: selection and definition of targets (lib, bins, examples, tests, benches)C-bugCategory: bugCommand-rustdocS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions