-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[rustdoc] Correctly handle output options with --show-coverage #159411
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
Open
GuillaumeGomez
wants to merge
7
commits into
rust-lang:main
Choose a base branch
from
GuillaumeGomez:show-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8aafa5e
[rustdoc] Correctly handle output options with `--show-coverage`
GuillaumeGomez f545db6
Add regression test for `--show-coverage` output
GuillaumeGomez 65b6e98
Add small message to say where the output was generated
GuillaumeGomez 854bbe7
Fix `tests/run-make/rustdoc-show-coverage/rmake.rs` by requiring `nee…
GuillaumeGomez 098056a
Move `rustdoc-ui` `--show-coverage` tests into the `coverage` folder
GuillaumeGomez c680b50
Mention how the `-o` option behaves with the `--show-coverage` option
GuillaumeGomez 2762f10
Correctly handle path comparison on windows
GuillaumeGomez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pub struct Bar; | ||
|
|
||
| impl Bar { | ||
| pub fn foo() {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // This test ensures that `-o` option works as expected with `--show-coverage`. | ||
| // Regression test for <https://github.com/rust-lang/rust/issues/158929>. | ||
|
|
||
| //@ needs-target-std | ||
|
|
||
| use run_make_support::assertion_helpers::assert_contains_regex; | ||
| use run_make_support::rfs::{read_to_string, remove_file}; | ||
| use run_make_support::{path, rustdoc}; | ||
|
|
||
| fn run_rustdoc(extra_args: &[&str]) -> String { | ||
| rustdoc() | ||
| .input("foo.rs") | ||
| .arg("-Zunstable-options") | ||
| .arg("--show-coverage") | ||
| .args(extra_args) | ||
| .run() | ||
| .stdout_utf8() | ||
| } | ||
|
|
||
| fn check_print_stdout(extra_args: &[&str], stdout_check: &str) { | ||
| let out = run_rustdoc(extra_args); | ||
|
|
||
| // By default, it shouldn't have created a `doc` folder. | ||
| assert!(!path("doc").exists(), "`doc` folder created with {extra_args:?}"); | ||
| // It should have display its output on stdout. | ||
| assert!(out.starts_with(stdout_check), "{out:?} doesn't start with {stdout_check:?}"); | ||
| } | ||
|
|
||
| fn check_generate_file(ext: &str, extra_args: &[&str], file_check: &str) { | ||
| let mut args = extra_args.to_vec(); | ||
| args.push("-o"); | ||
| args.push("doc"); | ||
| let out = run_rustdoc(&args); | ||
|
|
||
| // By default, it shouldn't have created a `doc` folder. | ||
| assert!(path("doc").exists(), "`doc` folder not created with {args:?}"); | ||
| let file = format!("doc/foo.{ext}"); | ||
| assert!(path(&file).exists()); | ||
|
|
||
| assert_contains_regex(out, format!("Generated output into \"doc.foo\\.{ext}\"\\s")); | ||
|
|
||
| let content = read_to_string(&file); | ||
| assert!(content.starts_with(file_check), "{content:?} doesn't start with {file_check:?}"); | ||
| remove_file(file); | ||
| } | ||
|
|
||
| fn main() { | ||
| check_print_stdout(&[], "+-"); | ||
| check_print_stdout(&["-o", "-"], "+-"); | ||
| check_print_stdout(&["--output-format=json"], "{"); | ||
| check_print_stdout(&["--output-format=json", "-o", "-"], "{"); | ||
|
|
||
| // Now we check that it works with "-o something". | ||
| check_generate_file("txt", &[], "+-"); | ||
| check_generate_file("json", &["--output-format=json"], "{"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| //@ compile-flags:-Z unstable-options --show-coverage | ||
| //@ compile-flags:-Z unstable-options --show-coverage -o - | ||
| //@ check-pass | ||
|
|
||
| // an empty crate still has one item to document: the crate root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...utput-format-coveragejson-emit-depinfo.rs → ...utput-format-coveragejson-emit-depinfo.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| //@ compile-flags: --show-coverage --output-format=json --emit=dep-info -Zunstable-options | ||
| //@ compile-flags: --show-coverage --output-format=json --emit=dep-info -Zunstable-options -o - | ||
| //@ build-pass |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/rustdoc-ui/show-coverage-json.rs → ...rustdoc-ui/coverage/show-coverage-json.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/rustdoc-ui/show-coverage.rs → tests/rustdoc-ui/coverage/show-coverage.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's likely a remain when I was testing things around. Although considering we only need to set this information after the
returnin theif show_coverageblock just above, I guess it's fine.