-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 but with minor adjustments. This flag similarly takes in two paths, a prefix to replace and a replacement string.
- Loading branch information
1 parent
c03ea3d
commit d66718c
Showing
10 changed files
with
139 additions
and
18 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
13 changes: 13 additions & 0 deletions
13
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,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 | ||
|
||
//@ 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" | ||
//@ failure-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 10) ... FAILED | ||
|
||
failures: | ||
|
||
---- remapped_path/remap-path-prefix-failed-doctest-output.rs - SomeStruct (line 10) 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 10) | ||
|
||
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 | ||
|
||
//@ 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" | ||
//@ failure-status: 101 | ||
|
||
// 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 | ||
|