Skip to content
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

Merged
merged 1 commit into from
May 10, 2024

Commits on Dec 6, 2023

  1. 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).
    stevecheckoway committed Dec 6, 2023
    Configuration menu
    Copy the full SHA
    32687e6 View commit details
    Browse the repository at this point in the history