-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
rustdoc: Fix output coloring for doctest building & running #148868
Copy link
Copy link
Open
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.Category: This is a bug.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.Category: This is a bug.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
No status
Follow-up to PR #148834 and issue #148749.
--color=auto(the default) is respected when rendering doctest build errors*.{stdout,stderr}by compiletest which isn't a terminal, so--color=autobecomes indistinguishable from--color=neverCLICOLOR_FORCE=1to indirectly detect auto workingCLICOLOR_FORCE=1#148864 unless we find another solutionsupports_colortofalsefor no apparent reasondoctest::make::parse_source, run "color capability detection" on STDOUT by default not STDERR since we / libtest are outputting these diagnostics to STDOUT by default (as part of its normal output)rustdoc doctest.rs --test | catstill outputs colors STDOUT despite us piping STDOUT to a "non-terminal"rustdoc doctest.rs --test 2>/dev/nulloutputs no colors to STDOUT despite STDOUT being a terminal--no-capture(rustdoc: Tracking issue for command-line flag--no-capture#148116):rustdoc doctest.rs --test --no-capture -Zunstable-options 2>/dev/nullcorrectly disables colors for STDERR where the diagnostics landif rustdoc_options.no_capture { /* query STDOUT */ } else { /* query STDERR */ }is sufficient--test-args --no-capture(i.e., libtest's non-capturing mode)!no_capture, we basically also want to query STDERR if--test-args --no-capture(however scanning libtest's arguments would be super janky) sorustdoc doctest.rs --test --test-args --no-capture 2>/dev/nullcorrectly suppresses colors for STDERRCLICOLOR_FORCE=1#148864 (comment)