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

Tracking Issue for rustdoc --test-run-directory #84674

Closed
ehuss opened this issue Apr 28, 2021 · 4 comments · Fixed by #103682
Closed

Tracking Issue for rustdoc --test-run-directory #84674

ehuss opened this issue Apr 28, 2021 · 4 comments · Fixed by #103682
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Apr 28, 2021

Summary

This is a tracking issue for the --test-run-directory flag in rustdoc. This flag changes the directory where doctests are run. This was added to support changing the directory used while running rustdoc --test in a Cargo workspace. See rust-lang/cargo#9427 for more information.

Unresolved Questions

None at this time.

Implementation history

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

cc @Swatinem

@ehuss ehuss added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc labels Apr 28, 2021
@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed T-rustdoc labels May 7, 2021
@Swatinem
Copy link
Contributor

Request for Stabilization

I opened #103682 with the aim to stabilize this rustdoc flag, primarily to facilitate the cargo doctest-in-workspace flag, and to eventually making it the default.

Summary

The --test-run-directory flag in combination with --test allows specifying an explicit directory in which rustdoc will run the compiled doctests. The default, without this explicit flag, is to run the resulting doctest binaries in the same current working directory as rustdoc itself.

This flag is primarily the building block for the doctest-in-workspace cargo flag (See rust-lang/cargo#9427).

With that flag, doctests are handled consistently to unit- and integration tests: They will be compiled relative to the cargo workspace root, but they are run in the crate directory.

Documentation

The flag is currently not documented as part of the unstable rustdoc features.

Tests

Unresolved questions

  • Similar flags that allow hooking into or observing the side effects of rustdoc test compilation, such as --run-tool or --persist-doctests are not stable yet, and there does not seem to be a push to stabilization either.
  • The usefulness of this flag when invoking rustdoc manually might be limited. But it is a requirement for the cargo doctest-in-workspace flag.
  • ☝🏻 Is there maybe a better alternative to solve the compile/run directory inconsistency that exists in cargo workspaces today?

@Swatinem
Copy link
Contributor

Swatinem commented Nov 9, 2022

@ehuss over in rust-lang/cargo#9427 (comment) expressed agreement to make the doctest-in-workspace cargo flag the default, considering it rather a bugfix for the current inconsistent behavior.

However, stabilizing --test-run-directory is a requirement for that, and there does not seem to be a better alternative to it.

@GuillaumeGomez is there anything I can do to move stabilization (#103682) forward?

@GuillaumeGomez
Copy link
Member

Next step is the FCP. I'll start on the PR.

@DXist
Copy link

DXist commented Feb 20, 2023

cargo test runs doc tests by default and doesn't allow to specify --test-run-directory.

My project uses sqlx which tries to create target/sqlx/<crate_name>/ directory. But if fails because I run the build inside a container against immutable source.

Instead I expect that the test should stay in the workspace directory and use <workspace_root>/target which is mounted as a build cache volume.

@bors bors closed this as completed in 9aa24fd Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants