Skip to content

rustdoc --persist-doctests does not work with --test-run-directory #112191

Closed
@ehuss

Description

@ehuss

The combination of --persist-doctests doesn't seem to work with --test-run-directory.

Reproduction:

  1. mkdir foo

  2. cd foo

  3. mkdir subdir

  4. Create subdir/example.rs with the contents:

    /// ```
    /// example::foo();
    /// ```
    pub fn foo() {}
  5. rustc --crate-type=rlib subdir/example.rs

  6. Verify a basic test works: rustdoc --edition=2021 -L . --test subdir/example.rs

  7. Verify that persist-doctests works: rustdoc --edition=2021 -L . --test subdir/example.rs --persist-doctests persist -Zunstable-options

  8. Verify that test-run-directory works: rustdoc --edition=2021 -L . --test subdir/example.rs --test-run-directory=subdir

  9. Check behavior when both are specified: rustdoc --edition=2021 -L . --test subdir/example.rs --test-run-directory=subdir --persist-doctests persist -Zunstable-options

Expected behavior: Tests should run successfully.

Actual behavior: Test fails with this error:


running 1 test
test subdir/example.rs - foo (line 1) ... FAILED

failures:

---- subdir/example.rs - foo (line 1) stdout ----
Couldn't run the test: No such file or directory (os error 2)

failures:
    subdir/example.rs - foo (line 1)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (9d871b061 2023-05-21)
binary: rustc
commit-hash: 9d871b0617a4b3d6610b7cee0ab5310dcb542c62
commit-date: 2023-05-21
host: aarch64-apple-darwin
release: 1.71.0-nightly
LLVM version: 16.0.4

cc #56925

Metadata

Metadata

Assignees

Labels

A-doctestsArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions