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

rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests #98708

Merged
merged 1 commit into from
Jul 2, 2022

Conversation

pinkforest
Copy link
Contributor

@pinkforest pinkforest commented Jun 30, 2022

Closes #98690 for rustdoc panic

I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic

~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs
Couldn't create directory for doctest executables: Permission denied (os error 13)

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jun 30, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @CraftSpider (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 30, 2022
@pinkforest
Copy link
Contributor Author

r? @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

Can you add a rustdoc-ui test please?

@GuillaumeGomez
Copy link
Member

Hum actually, I'm not sure if it's possible to check this one in CI... Maybe you have an idea @notriddle @camelid ?

@pinkforest pinkforest changed the title rustdoc: fix 98690 - Panic if UNC path used for -Z persist-doctests rustdoc: fix 98690 - Panic if invalid path used for -Z persist-doctests Jun 30, 2022
@pinkforest pinkforest changed the title rustdoc: fix 98690 - Panic if invalid path used for -Z persist-doctests rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests Jun 30, 2022
@pinkforest
Copy link
Contributor Author

Yeah I tried to find CLI tests but there didn't seem anything to plug into.. would have to come up with something I think on another PR?

My first PR sorry.. 🦄

@GuillaumeGomez
Copy link
Member

Don't worry, if it requires developing something new, we will just approve this PR and do it in another PR. I'm just checking I didn't miss something.

@pinkforest
Copy link
Contributor Author

pinkforest commented Jun 30, 2022

I tried to add in src/test/rustdoc/isue-98690.rs - however CI has access to / so I am wondering how I can simulate invalid path here as std::fs::create_dir_all(&path) on ubuntu-latest is very forgiving that regard

// compile-flags: --persist-doctests /cannot_write_here -Z unstable-options

#![crate_name = "foo"]

//! ```
//! use foo::dummy;
//! dummy();
//! ```

I am not even sure if the above would catch runtime panic and I cannot check the result of eprintln or not sure about negative tests

However it does catch non-panic exit(1) code say if I would have invalid arguments e.g. adding extra -hfff to cli:

---- [rustdoc] src/test/rustdoc/issue-98690.rs stdout ----

error: rustdoc failed!
status: exit status: 1
command: "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "-L" "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-L" "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/test/rustdoc/issue-foo/auxiliary" "-o" "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/test/rustdoc/issue-foo" "--deny" "warnings" "/home/foobar/gg/rust/src/test/rustdoc/issue-foo.rs" "--persist-doctests" "/cannot_write_here" "-Z" "unstable-options" "-hfff"
stdout: none
--- stderr -------------------------------
error: Unrecognized option: 'f'
------------------------------------------

The test failures on that fn were relying on the same method I was using to roll exit so I followed that without using exit codes

@GuillaumeGomez
Copy link
Member

Oh that's because you need to put it into rustdoc-ui, not rustdoc. Then you need to add an .stderr alongside your .rs where the output will be.

@pinkforest
Copy link
Contributor Author

pinkforest commented Jun 30, 2022

Ah that's helpful.. I think /../../ will work in CI to simulate invalid path:

---- [ui] src/test/rustdoc-ui/issue-98690.rs stdout ----

error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit status: 101
command: "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc" "/home/foobar/gg/rust/src/test/rustdoc-ui/issue-foo.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "-o" "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-ui/issue-foo" "-Cdebuginfo=0" "-Lnative=/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--test" "--persist-doctests" "/../../" "-Z" "unstable-options" "-L" "/home/foobar/gg/rust/build/x86_64-unknown-linux-gnu/test/rustdoc-ui/issue-foo/auxiliary"
stdout: none
--- stderr -------------------------------
Couldn't create directory for doctest executables: Permission denied (os error 13)
------------------------------------------

rust/src/test/rustdoc-ui$ cat issue-68690.stderr

Couldn't create directory for doctest executables: Permission denied (os error 13)

I updated stderr but it is expecting exit status code 1 if I intepret the above correct

However this would be different to rest of the test errors if I just exit the whole program

Is there a way to put exit code 101 into test data as expected exit condition or should I exit with 1 code ?

EDIT: // failure-status: 101 - gotcha!

@pinkforest
Copy link
Contributor Author

pinkforest commented Jun 30, 2022

Added a test :) this will now test for the error out - Thanks for the help 💜 @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

I didn't even have time to answer you. Great work and thanks a lot for this! (It allowed me to discover few things on the tests too 😆 )

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 30, 2022

📌 Commit 29e0e14 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 30, 2022
…llaumeGomez

rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests

Closes rust-lang#98690 for rustdoc panic

I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic

~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs
Couldn't create directory for doctest executables: Permission denied (os error 13)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 30, 2022
…llaumeGomez

rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests

Closes rust-lang#98690 for rustdoc panic

I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic

~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs
Couldn't create directory for doctest executables: Permission denied (os error 13)
@matthiaskrgr
Copy link
Member

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 30, 2022
@GuillaumeGomez
Copy link
Member

Let's go again!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 30, 2022

📌 Commit 29e0e14 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 30, 2022
…llaumeGomez

rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests

Closes rust-lang#98690 for rustdoc panic

I changed this to do eprintln and orderly panic instead of unwrap doing unhandled panic

~/gg/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustdoc --test -Z unstable-options --persist-doctests /tmp/foobar main.rs
Couldn't create directory for doctest executables: Permission denied (os error 13)
@notriddle
Copy link
Contributor

notriddle commented Jul 1, 2022

@bors r-

Failed in rollup #98744

No idea why the test harness comment failed. only-linux should have worked.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 1, 2022
@pinkforest
Copy link
Contributor Author

The only other test that has only-windows it's the first header

I tried to briefly look for reason why it gets ignored from here:
https://github.com/Manishearth/compiletest-rs/blob/master/src/header.rs

It doesn't seem (by reading fn header_iter) that header placement should have any issue though

@pinkforest
Copy link
Contributor Author

pinkforest commented Jul 1, 2022

Ok it looks like rollup picked up the wrong commit thanks @ehuss and @jyn514 for the help
Bors says this:
Commit https://github.com/rust-lang/rust/commit/29e0e148d9336bd554a4ef400f628f4a21413349 has been approved by GuillaumeGomez

EDIT: Bors picked up the wrong commit for reason or another
EDIT.2: Solution may be to re-open the PR

@pinkforest pinkforest closed this Jul 1, 2022
@pinkforest pinkforest reopened this Jul 1, 2022
@ehuss
Copy link
Contributor

ehuss commented Jul 1, 2022

@bors r=GuillaumeGomez rollup

@bors
Copy link
Contributor

bors commented Jul 1, 2022

📌 Commit 6565509 has been approved by GuillaumeGomez

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2022
…laumeGomez

Rollup of 5 pull requests

Successful merges:

 - rust-lang#97249 (`<details>`/`<summary>` UI fixes)
 - rust-lang#98418 (Allow macOS to build LLVM as shared library)
 - rust-lang#98460 (Use CSS variables to handle theming)
 - rust-lang#98497 (Improve some inference diagnostics)
 - rust-lang#98708 (rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests)

Failed merges:

 - rust-lang#98761 (more `need_type_info` improvements)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 00d68a7 into rust-lang:master Jul 2, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 2, 2022
@MinxuanZ
Copy link
Contributor

Will this test fail if tested with root ?

@GuillaumeGomez
Copy link
Member

Do you have an example in mind?

@MinxuanZ
Copy link
Contributor

// compile-flags: --test --persist-doctests /../../ -Z unstable-options
// failure-status: 101
// only-linux

#![crate_name = "foo"]

//! ```rust
//! use foo::dummy;
//! dummy();
//! ```

image

root user have permission to create dir in /../../ , stderr is different

@GuillaumeGomez
Copy link
Member

That sounds like the expected behaviour, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic if invalid path used for -Z persist-doctests
10 participants