Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in CWD for doctests #8992

Closed
jan-auer opened this issue Dec 17, 2020 · 0 comments · Fixed by #8996
Closed

Regression in CWD for doctests #8992

jan-auer opened this issue Dec 17, 2020 · 0 comments · Fixed by #8996
Labels
C-bug Category: bug

Comments

@jan-auer
Copy link

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"));
//! ```
@jan-auer jan-auer added the C-bug Category: bug label Dec 17, 2020
@bors bors closed this as completed in 8abc050 Dec 18, 2020
Swatinem added a commit to Swatinem/cargo that referenced this issue Jan 2, 2021
To avoid regressions to the test runtime directory, this asserts that
all test types (unit, integration, doctest) are executed in the crate
(manifest) directory, no matter where that crate is in relation to the
workspace root.

See rust-lang#8992 / rust-lang#8993
bors added a commit that referenced this issue Jan 4, 2021
Assert that tests are run in the crate directory

To avoid regressions to the test runtime directory, this asserts that
all test types (unit, integration, doctest) are executed in the crate
(manifest) directory, no matter where that crate is in relation to the
workspace root.

See #8992 / #8993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant