-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Color test output and shorten chapter paths #2259
Conversation
ae5d06a
to
c7f9390
Compare
Currently, the output from `rustdoc --test` is not colored because `rustdoc`'s stdout is not a tty. The output of a failed `rustdoc` run is sent to `mdbook`'s stderr via the `error!()` macro. This commit checks if stderr is a tty using the standard `.is_terminal()` and if so, passes `--color always` to `rustdoc`. The test output from `rustdoc` includes the full path that `rustdoc` was called with. This obscures the path of the file with the error. E.g., ``` ---- /var/folders/9v/90bm7kb10fx3_bprxltb3t1r0000gn/T/mdbook-tnGJxp/lab0/index.md - Lab_0__Getting_Started (line 3) stdout ---- error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `code` --> /var/folders/9v/90bm7kb10fx3_bprxltb3t1r0000gn/T/mdbook-tnGJxp/lab0/index.md:4:6 | 3 | this code has a bug | ^^^^ expected one of 8 possible tokens error: aborting due to previous error ``` This commit runs `rustdoc` in the temp directory and replaces any relative library paths with absolute library paths. This leads to simpler error messages. The one above becomes ``` ---- lab0/index.md - Lab_0__Getting_Started (line 3) stdout ---- error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `code` --> lab0/index.md:4:6 | 3 | this code has a bug | ^^^^ expected one of 8 possible tokens error: aborting due to previous error ``` (with colors, of course).
c7f9390
to
d61990c
Compare
I realized after creating this PR that I had accidentally included an unrelated change that causes I split the commit into two different commits. The first commit makes the changes described above. The second commit just adds these command line options. I'm happy to drop the second commit, but the |
d61990c
to
32687e6
Compare
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.
Thanks! I went ahead and dropped the second commit. -C embed-bitcode=no
has no effect, since rustdoc is only generating executables, and those do not have bitcode. And --error-format=human
is the default, so there shouldn't be a need to set that.
Currently, the output from
rustdoc --test
is not colored becauserustdoc
's stdout is not a tty. The output of a failedrustdoc
run is sent tomdbook
's stderr via theerror!()
macro. This commit checks if stderr is a tty using the standard.is_terminal()
and if so, passes--color always
torustdoc
.The test output from
rustdoc
includes the full path thatrustdoc
was called with. This obfuscates the file with the error. E.g.,This commit runs
rustdoc
in the temp directory and replaces any relative library paths with absolute library paths. This leads to simpler error messages. The one above becomes(with colors, of course).