Skip to content

[feat] cargo should explain doctest binary path location #15432

Open
@loynoir

Description

@loynoir

Problem

cargo does not explain doctest binary path location

Thus, need to hard code doctest binary path location.

https://doc.rust-lang.org/rustc/instrument-coverage.html#including-doc-tests

$ llvm-cov report \
    $( \
      for file in \
        $( \
          RUSTFLAGS="-C instrument-coverage" \
          RUSTDOCFLAGS="-C instrument-coverage -Z unstable-options --persist-doctests target/debug/doctestbins" \
            cargo test --no-run --message-format=json \
              | jq -r "select(.profile.test == true) | .filenames[]" \
              | grep -v dSYM - \
        ) \
        target/debug/doctestbins/*/rust_out; \
      do \
        [[ -x $file ]] && printf "%s %s " -object $file; \
      done \
    ) \
  --instr-profile=json5format.profdata --summary-only # and/or other options

Proposed Solution

cargo should explain doctest binary path location

$ "${cmd[@]}" --no-run --message-format=json | jq -r ".filenames[]" | grep doctestbins
target/debug/doctestbins/XXX/rust_out
target/debug/doctestbins/XXX/rust_out
target/debug/doctestbins/XXX/rust_out

Notes

channel = "nightly-2025-04-14"

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: rustdoc --testA-json-outputArea: JSON message outputC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-testS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions