forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#107099 - edward-shen:edward-shen/rustdoc-rema…
…p-path-prefix, r=GuillaumeGomez rustdoc: Add support for --remap-path-prefix Adds `--remap-path-prefix` as an unstable option. This is implemented to mimic the behavior of `rustc`'s `--remap-path-prefix`. This flag similarly takes in two paths, a prefix to replace and a replacement string. This is useful for build tools (e.g. Buck) other than cargo that can run doc tests. cc: `@dtolnay`
- Loading branch information
Showing
11 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
14 changes: 14 additions & 0 deletions
14
tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs
This file contains 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,14 @@ | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
//@ failure-status: 101 | ||
//@ compile-flags:--test -Z unstable-options --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1 | ||
//@ rustc-env:RUST_BACKTRACE=0 | ||
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ normalize-stdout-test "exit (status|code): 101" -> "exit status: 101" | ||
|
||
// doctest fails at runtime | ||
/// ``` | ||
/// panic!("oh no"); | ||
/// ``` | ||
pub struct SomeStruct; |
21 changes: 21 additions & 0 deletions
21
tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout
This file contains 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,21 @@ | ||
|
||
running 1 test | ||
test remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11) ... FAILED | ||
|
||
failures: | ||
|
||
---- remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11) stdout ---- | ||
Test executable failed (exit status: 101). | ||
|
||
stderr: | ||
thread 'main' panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1: | ||
oh no | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace | ||
|
||
|
||
|
||
failures: | ||
remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 11) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains 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,13 @@ | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
//@ failure-status: 101 | ||
//@ compile-flags:--test -Z unstable-options --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1 | ||
//@ rustc-env:RUST_BACKTRACE=0 | ||
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
|
||
// doctest fails to compile | ||
/// ``` | ||
/// this is not real code | ||
/// ``` | ||
pub struct SomeStruct; |
This file contains 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,22 @@ | ||
|
||
running 1 test | ||
test remapped_path/remap-path-prefix-invalid-doctest.rs - SomeStruct (line 10) ... FAILED | ||
|
||
failures: | ||
|
||
---- remapped_path/remap-path-prefix-invalid-doctest.rs - SomeStruct (line 10) stdout ---- | ||
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `is` | ||
--> remapped_path/remap-path-prefix-invalid-doctest.rs:11:6 | ||
| | ||
LL | this is not real code | ||
| ^^ expected one of 8 possible tokens | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
remapped_path/remap-path-prefix-invalid-doctest.rs - SomeStruct (line 10) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
14 changes: 14 additions & 0 deletions
14
tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs
This file contains 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,14 @@ | ||
//@ check-pass | ||
//@ check-run-results | ||
|
||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
//@ compile-flags:--test -Z unstable-options --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1 | ||
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
|
||
// doctest passes at runtime | ||
/// ``` | ||
/// assert!(true); | ||
/// ``` | ||
pub struct SomeStruct; |
6 changes: 6 additions & 0 deletions
6
tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.stdout
This file contains 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,6 @@ | ||
|
||
running 1 test | ||
test remapped_path/remap-path-prefix-passed-doctest-output.rs - SomeStruct (line 11) ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|