Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Color test output and shorten chapter paths
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).
- Loading branch information