You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking Issue for rustdoc --test-run-directory #84674
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.
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.
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.
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?
@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.
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.
Activity
Swatinem commentedon Oct 28, 2022
Request for Stabilization
I opened #103682 with the aim to stabilize this rustdoc flag, primarily to facilitate the cargo
doctest-in-workspaceflag, and to eventually making it the default.Summary
The
--test-run-directoryflag in combination with--testallows 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-workspacecargo 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
std::fsfunctions inside doctests.doctest-in-workspaceflag.Unresolved questions
--run-toolor--persist-doctestsare not stable yet, and there does not seem to be a push to stabilization either.rustdocmanually might be limited. But it is a requirement for the cargodoctest-in-workspaceflag.Swatinem commentedon Nov 9, 2022
@ehuss over in rust-lang/cargo#9427 (comment) expressed agreement to make the
doctest-in-workspacecargo flag the default, considering it rather a bugfix for the current inconsistent behavior.However, stabilizing
--test-run-directoryis 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 commentedon Nov 9, 2022
Next step is the FCP. I'll start on the PR.
DXist commentedon 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>/targetwhich is mounted as a build cache volume.Rollup merge of rust-lang#103682 - Swatinem:stable-run-directory, r=G…