1

Github Run rustdoc doctests relative to the workspace by Swatinem · Pull Request...

 1 year ago
source link: https://github.com/rust-lang/cargo/pull/9105
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

New issue

Run rustdoc doctests relative to the workspace #9105

Conversation

Copy link

Contributor

Swatinem commented on Jan 26

By doing so, rustdoc will also emit workspace-relative filenames for the doctests.

This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.

The second try relies on the new --test-run-directory rustdoc option which was added in rust-lang/rust#81264 to explicitly control the rustdoc test cwd.

fixes #8993

r? @Eh2406

(rust-highfive has picked a reviewer for you, use r? to override)

Copy link

Contributor

Author

Swatinem commented on Jan 26

r? @alexcrichton

CC @jyn514

This is currently blocked by having a rustdoc that supports that new flag. I did a "rustup update nightly" locally, but either its not in there yet, or cargo does not run the tests with nightly? Not sure… How can I control this?

Copy link

Member

alexcrichton commented on Jan 26

Thanks! Unfortunately due to the use of -Z we won't be able to unconditionally enable this in Cargo. One option is to add a similar -Z flag to Cargo, or we could wait for the rustdoc option to stabilize to land this.

Copy link

Contributor

bors commented on Feb 3

umbrella The latest upstream changes (presumably #9122) made this pull request unmergeable. Please resolve the merge conflicts.

Swatinem

force-pushed the

Swatinem:rustdoc-run-cwd

branch 4 times, most recently from 58cc481 to c4667b2

on Feb 12

Swatinem

marked this pull request as ready for review

29 days ago

Copy link

Contributor

Author

Swatinem commented 29 days ago

I updated the code to be compatible with both stable and nightly Rust but adding a few more conditions to the testsuite.

I remember @jyn514 said there is no problem with stabilizing this option in rustdoc immediately as long as we validate that it actually does its job well.

Due to the fact that cargo compiles/runs its testsuite on stable as well, I do think this needs to ride the trains to be turned on in cargo?

Copy link

Member

jyn514 commented 29 days ago

Due to the fact that cargo compiles/runs its testsuite on stable as well, I do think this needs to ride the trains to be turned on in cargo?

Normally nightly tests are skipped when running with a stable toolchain I think. It seems strange to delay this just for the test suite.

p.arg("--crate-name").arg(&unit.target.crate_name());

p.arg("--test");

if nightly_features_allowed() {

Swatinem 29 days ago

Author

Contributor

point_up@jyn514 This is what I mean; removing this, every test that does a doctest will fail when run against stable rustc (up until it rides the trains)

jyn514 29 days ago

Member

I don't understand the problem; why do you want to remove if nightly_features_allowed? That seems like the right check.

If it helps, cargo always runs against the same toolchain version of rustc; if cargo is nightly, rustc will be nightly too.

Swatinem 28 days ago

Author

Contributor

I mean, this should get into stable at some point…

jyn514 28 days ago

Member

Oh - that has to wait for rustdoc to stabilize the option. The plan is

  • add the nightly feature in rustdoc
  • pass it automatically in nightly cargo (this PR)
  • stabilize the feature in rustdoc
  • pass the flag unconditionally in cargo

alexcrichton 20 days ago

Member

I think that this should probably be gated by a specific -Z flag in Cargo rather than simply unconditionally on the nightly channel

alexcrichton 20 days ago

Member

That'll also make the impact in the tests less because the new changes will have to be opted-into instead of automatically happening on nightly.

Swatinem 20 days ago

Author

Contributor

+1 fair enough! Rebased and added an unstable option that controls this behavior. That should be well enough for my purposes.

Copy link

Contributor

bors commented 29 days ago

umbrella The latest upstream changes (presumably #8640) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link

Member

alexcrichton commented 19 days ago

@bors: r+

Looks good to me, thanks!

Copy link

Contributor

bors commented 19 days ago

pushpin Commit b4c4028 has been approved by alexcrichton

Copy link

Contributor

bors commented 19 days ago

hourglass Testing commit b4c4028 with merge 6243e8e...

Copy link

Contributor

bors commented 19 days ago

sunny Test successful - checks-actions
Approved by: alexcrichton
Pushing 6243e8e to master...

bors

merged commit 6243e8e into rust-lang:master 19 days ago

13 checks passed

Swatinem

deleted the

Swatinem:rustdoc-run-cwd

branch

18 days ago

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects

None yet

Milestone

No milestone

Linked issues

Successfully merging this pull request may close these issues.

7 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK