Skip to content

Regression in CWD for doctests #8992

Closed
@jan-auer

Description

@jan-auer

Problem
cargo 1.50.0-nightly changes the current working directory for doctests when executed from a workspace. Instead of the crate's root, the workspace's root is assumed. The regression originates in #8954. I think, the cwd should still point to the crate root in all cases.

Steps

  1. Crate a workspace with a member crate in a subdirectory.
  2. Write a doctest that reads a file relative to the crate root, e.g. src/lib.rs.
  3. Test with cargo +stable test --workspace and observe the test pass.
  4. Test with cargo +nightly test --workspace and observe the test fail.

Possible Solution(s)

Notes

Output of cargo version: cargo 1.50.0-nightly (d274fcf86 2020-12-07)

Example src/lib.rs for a workspace member that will pass on stable but fail on nightly:

//! ```
//! assert_eq!(std::fs::read_to_string("src/lib.rs").unwrap(), include_str!("lib.rs"));
//! ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions